<template>
  <div
    v-if="dialogTableVisible"
    :fullscreen="false"
    :modal="false"
    :show-close="false"
    :width="screenWidth + 20 + 'px'"
    :append-to-body="true"
    style="
      position: absolute;
      left: 6rem;
      margin-top: 42px;
      z-index: 10;
      background-color: white;
    "
    :close-on-click-modal="false"
  >
    <div :style="{ width: screenWidth - 96 + 'px' }">
      <div
        :style="{
          height: '40px',
          borderBottom: '1px solid #ccc',
          width: '100%',
        }"
      >
        <div style="position: absolute; right: 15px">
          <!-- <el-button @click="flushed" type="primary"> 刷新</el-button> -->
          <!-- <el-button @click="addRow" type="primary">增行</el-button> -->
          <!-- <el-button @click="deleteSelectedRows" type="danger">删除</el-button> -->
          <el-button
            type="primary"
            @click="getAllData(ruleFormRef)"
            v-if="showInsertButton"
            >保存</el-button
          >
          <el-button
            type="primary"
            @click="updateMaterialsFixed(ruleFormRef)"
            v-if="!showInsertButton"
            >保存</el-button
          >
          <!-- <el-button
            type="primary"
            @click="getAllData3(ruleFormRef)"
            v-if="!showInsertButton"
            >修改提交事件</el-button
          >
          <el-button
            type="primary"
            @click="getAllData1(ruleFormRef)"
            v-if="showInsertButton"
            >赋值</el-button
          >
          <el-button
            type="primary"
            @click="updateMaterialsFixed1(ruleFormRef)"
            v-if="!showInsertButton"
            >赋值1</el-button
          > -->

          <el-button @click="OFFdialogTableVisible" type="danger">关闭</el-button>
        </div>
      </div>

      <div
        ref="titleDiv"
        :style="{
          backgroundColor: 'rgba(247, 247, 247, 0.903)',
          height: 100 + 'px',
          width: screenWidth - 96 + 'px',
        }"
      >
        <el-form :model="formMainTable" :inline="true">
          <el-form-item class="labs" style="margin-right: 0">
            <label class="lab" style="width: 100px; padding-right: 5px">标准编号</label>
            <el-input
              style="width: 180px"
              v-model="formMainTable.processCode"
              placeholder="自动生成"
              disabled
              clearable
            />
          </el-form-item>
          <el-form-item class="labs" style="margin-right: 0">
            <label class="lab" style="width: 100px; padding-right: 5px"
              ><span style="color: red; font-weight: 700">*</span>标准名称</label
            >
            <el-input
              style="width: 180px"
              v-model="formMainTable.processName"
              clearable
            />
          </el-form-item>
          <el-form-item class="labs" style="margin-right: 0">
            <label class="lab" style="width: 100px; padding-right: 5px"> 标准类型 </label>
            <el-select
              v-model="formMainTable.standardType"
              style="width: 180px"
              :readonly="true"
              @change="clickOrganizationSelect()"
            >
              <el-option label="专用标准" value="1"></el-option>
              <el-option label="通用标准" value="0"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item class="labs" style="margin-right: 0">
            <label class="lab" style="width: 100px; padding-right: 5px"> 类型 </label>
            <el-select
              v-model="formMainTable.type"
              style="width: 180px"
              :readonly="true"
              @change="clickOrganizationSelect1()"
            >
              <el-option label="磨削标准" value="0"></el-option>
              <el-option label="安装标准" value="1"></el-option>
              <el-option label="拆卸标准" value="2"></el-option>
            </el-select>
          </el-form-item>

          <el-form :model="formMainTable" :inline="true">
            <el-form-item class="labs" style="margin-right: 0">
              <label class="lab" style="width: 100px; padding-right: 5px">
                <span style="color: red; font-weight: 700">*</span> 设备结构</label
              >
              <el-input
                style="width: 180px"
                v-model="formMainTable.structureName"
                :readonly="true"
                @click="openEqipmentParts()"
                clearable
              />
            </el-form-item>
            <el-form-item class="labs" style="margin-right: 0">
              <label class="lab" style="width: 100px; padding-right: 5px">
                <span style="color: red; font-weight: 700">*</span> 设备零件</label
              >
              <el-input
                style="width: 180px"
                v-model="formMainTable.name"
                :readonly="true"
                @click="openEqipmentParts()"
                clearable
              />
            </el-form-item>

            <el-form-item class="labs" style="margin-right: 0">
              <label class="lab" style="width: 100px; padding-right: 5px">
                <span style="color: red; font-weight: 700">*</span>型号</label
              >
              <el-input
                style="width: 180px"
                v-model="formMainTable.modelName"
                :readonly="true"
                @click="openEqipmentParts()"
                clearable
              />
            </el-form-item>
            <el-form-item class="labs" style="margin-right: 0">
              <label class="lab" style="width: 100px; padding-right: 5px">
                <span style="color: red; font-weight: 700">*</span> 耗材类别</label
              >
              <el-input
                style="width: 180px"
                v-model="formMainTable.consumableCategoryName"
                :readonly="true"
                @click="openEqipmentParts()"
                clearable
              />
            </el-form-item>
          </el-form>
          <el-form :model="formMainTable" :inline="true">
            <el-form-item class="labs" style="margin-right: 0">
              <label class="lab" style="width: 100px; padding-right: 5px">
                <span style="color: red; font-weight: 700">*</span>产品用途</label
              >
              <el-input
                style="width: 180px"
                v-model="formMainTable.productPurposeName"
                :readonly="true"
                @click="openEqipmentParts1()"
                clearable
              />
            </el-form-item>
            <el-form-item class="labs" style="margin-right: 0">
              <label class="lab" style="width: 100px; padding-right: 5px">
                <span style="color: red; font-weight: 700">*</span>材质:</label
              >
              <el-input
                style="width: 180px"
                v-model="formMainTable.materialName"
                :readonly="true"
                @click="openEqipmentParts2()"
                clearable
              />
            </el-form-item>
            <!-- procedures -->
            <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
              <label class="lab" style="width: 100px; padding-right: 5px"> 工序</label>
              <el-select
                v-model="formMainTable.procedures"
                style="width: 180px"
                :readonly="true"
              >
                <el-option label="轧机" value="0"></el-option>
                <el-option label="退火" value="1"></el-option>
                <el-option label="拉矫" value="2"></el-option>
                <el-option label="分条" value="3"></el-option>
                <el-option label="清洗线" value="4"></el-option>
                <el-option label="破带" value="5"></el-option>
                <el-option label="大分条" value="6"></el-option>
                <el-option label="去应力" value="7"></el-option>
                <el-option label="贴膜" value="8"></el-option>
                <el-option label="研磨" value="9"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
              <label class="lab" style="width: 100px; padding-right: 5px">
                工序属性</label
              >
              <el-select
                v-model="formMainTable.processProperty"
                style="width: 180px"
                :readonly="true"
                @change="openprocessProperty()"
              >
                <el-option label="——————" value="0"></el-option>
                <el-option label="成品" value="1"></el-option>
                <el-option label="半成品" value="2"></el-option>
                <!-- <el-option label="分条成品" value="3"></el-option>
                <el-option label="分条半成品" value="4"></el-option> -->
                <el-option label="成品,半成品" value="5"></el-option>
              </el-select>
            </el-form-item>

            <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
              <label class="lab" style="width: 100px; padding-right: 5px">
                磨削道次数</label
              >
              <el-input
                style="width: 180px"
                v-model="formMainTable.passToolNumber"
                @blur="handleInput('passToolNumber')"
                clearable
              />
            </el-form-item>
            <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
              <label class="lab" style="width: 100px; padding-right: 5px"> 说明</label>
              <el-input style="width: 180px" v-model="formMainTable.explain" clearable />
            </el-form-item>
          </el-form>
        </el-form>
      </div>
      <div
        :style="{
          backgroundColor: 'rgba(247, 247, 247, 0.903)',
          height: collapsed + 'px',
          width: screenWidth - 96 + 'px',
        }"
      >
        <el-collapse v-model="activeNames" @change="handleChange" v-if="!isMx">
          <el-collapse-item :title="dynamicTitle" name="1">
            <template #title>
              <div class="custom-collapse-title">{{ dynamicTitle }}</div>
            </template>
            <el-form :model="formMainTable" :inline="true">
              <el-form :model="formMainTable" :inline="true">
                <el-form-item class="labs" style="margin-right: 0">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    成品厚度</label
                  >
                  <!--   @blur="handleInput('finishedThickness')" -->
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.finishedThickness"
                    clearable
                  />
                </el-form-item>
                <!--   @blur="handleInput('finishedWidth')" -->
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    成品宽度</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.finishedWidth"
                    clearable
                  />
                </el-form-item>
              </el-form>

              <el-form :model="formMainTable" :inline="true" v-if="!isMx">
                <el-form-item class="labs" style="margin-right: 0">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    硬度范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.hardnessRange"
                    clearable
                    placeholder="0.00-1.00"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    延伸率范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.elongationRange"
                    clearable
                    placeholder="0.00-1.00"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    屈服范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.yieldRange"
                    clearable
                    placeholder="0.00-1.00"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    抗拉范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.tensileRange"
                    clearable
                    placeholder="0.00-1.00"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    成品粗糙度范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.surfaceRoughnessRange"
                    clearable
                    placeholder="0.00-1.00"
                  />
                </el-form-item>
              </el-form>

              <el-form :model="formMainTable" :inline="true" v-if="!isMx">
                <el-form-item class="labs" style="margin-right: 0">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Ti元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.tiElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Ta元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.taElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Nb元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.nbElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Al元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.alElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Zr元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.zrElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
              </el-form>
              <el-form :model="formMainTable" :inline="true" v-if="!isMx">
                <el-form-item class="labs" style="margin-right: 0">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    U元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.uElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    B元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.bElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Fe元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.feElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Co元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.coElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    W元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.wElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
              </el-form>
              <el-form :model="formMainTable" :inline="true">
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    H元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.hElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    O元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.oElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    C元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.cElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Si元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.siElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Mn元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.mnElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
              </el-form>
              <el-form :model="formMainTable" :inline="true" v-if="!isMx">
                <el-form-item class="labs" style="margin-right: 0">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    P元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.pElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    S元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.sElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Cr元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.crElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Ni元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.niElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Mo元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.moElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
              </el-form>
              <el-form :model="formMainTable" :inline="true">
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    Cu元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.cuElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    N元素范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.nElementRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    硬化系数范围</label
                  >
                  <el-input
                    style="width: 180px"
                    v-model="formMainTable.hardenabilityRange"
                    clearable
                    placeholder="0.00-1.00"
                    :disabled="isDisabledleri"
                  />
                </el-form-item>
                <el-form-item class="labs" style="margin-right: 0" v-if="!isMx">
                  <label class="lab" style="width: 100px; padding-right: 5px">
                    标准详述</label
                  >
                  <el-input
                    style="width: 500px"
                    v-model="formMainTable.standardDetails"
                    clearable
                    disabled
                  />
                </el-form-item>
              </el-form>
            </el-form>
          </el-collapse-item>
        </el-collapse>
      </div>
      <el-scrollbar :style="{ height: scollbarHeight + 'px' }">
        <div>
          <el-row>
            <el-col :span="2">
              <div style="max-width: 200px; max-height: 500px; overflow: auto">
                <el-affix :offset="affixOffset">
                  <el-anchor
                    :container="containerRef"
                    direction="vertical"
                    type="underline"
                    :offset="50"
                    style="white-space: normal; width: 150px"
                    @change="handleChangeAnchor"
                  >
                    <el-anchor-link
                      v-for="link in links"
                      :key="link.id"
                      :href="link.href"
                      :title="link.title"
                    />
                  </el-anchor>
                </el-affix>
              </div>
            </el-col>

            <el-col :span="22">
              <div ref="containerRef">
                <div
                  id="part1"
                  v-if="!isMx"
                  style="height: 280px; background: rgba(255, 0, 0, 0.02)"
                >
                  <div style="font-size: 1em; font-weight: bold">技术标准</div>
                  <el-scrollbar>
                    <el-table
                      ref="tableEle1"
                      :data="tableData1"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange1"
                      :header-cell-style="headerCellStyle1"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <!-- <el-table-column label="序号" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column> -->
                      <el-table-column label="项目" width="130" align="center">
                        <template #default="{ row, $index }">
                          <el-select
                            v-model="row.project"
                            placeholder="请选择"
                            disabled
                            :style="{ height: '25px' }"
                            size="small"
                          >
                            <el-option label="磨削量(mm)" value="0" />
                            <el-option label="粗糙度(um)" value="1" />
                            <el-option label="横移量" value="2" />
                            <el-option label="锥高比例" value="3" />
                            <el-option label="锥长(mm)" value="4" />
                            <el-option label="锥高(s)" value="5" />
                            <el-option label="钢带宽度(mm)" value="6" />
                            <el-option label="耗用量(mm)" value="7" />
                          </el-select>
                        </template>
                      </el-table-column>

                      <el-table-column label="标准" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.standard"
                            :style="{ height: '25px' }"
                            @blur="handleInput1(row, $index)"
                            :disabled="row.isDisabled0"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="公差上限" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.toleranceUpperLimit"
                            :style="{ height: '25px' }"
                            :disabled="row.isDisabled"
                            @blur="handleInput0(row, $index, 'toleranceUpperLimit')"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="公差下限" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.toleranceLowerLimit"
                            :style="{ height: '25px' }"
                            :disabled="row.isDisabled"
                            @blur="handleInput0(row, $index, 'toleranceLowerLimit')"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="值域" width="100" align="center">
                        <template #default="{ row, $index }">
                          <el-select
                            v-model="row.valueRangeType"
                            placeholder="请选择"
                            @change="handleValueRangeChange(row, $index)"
                            :style="{ height: '25px' }"
                            size="small"
                          >
                            <el-option label="精确值" value="0" />
                            <el-option label="公差值" value="1" />
                            <el-option label="描述值" value="2" />
                            <el-option label="范围值" value="3" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="备注" align="center">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-scrollbar>
                </div>
                <div
                  id="part2"
                  v-if="!isMx"
                  style="
                    height: 230px;
                    background: rgba(0, 255, 0, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div style="font-size: 1em; font-weight: bold">磨削道次</div>
                  <el-scrollbar>
                    <el-table
                      ref="tableEle2"
                      :data="tableData2"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange2"
                      :header-cell-style="headerCellStyle1"
                      :max-height="220 + 'px'"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <el-table-column label="道次序号" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column>

                      <el-table-column label="磨削数量" width="240" align="center">
                        <el-table-column label="标准" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                              <span style="color: red; font-weight: 700">*</span>
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.grindingQuantityStandard"
                              @blur="
                                handleInput2(row, $index, 'grindingQuantityStandard')
                              "
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>
                        <el-table-column label="公差上限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                              <span style="color: red; font-weight: 700">*</span>
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.grindingQuantityToleranceUpperLimit"
                              :style="{ height: '25px' }"
                              @blur="
                                handleInput2(
                                  row,
                                  $index,
                                  'grindingQuantityToleranceUpperLimit'
                                )
                              "
                            />
                          </template>
                        </el-table-column>
                        <el-table-column label="公差下限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                              <span style="color: red; font-weight: 700">*</span>
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.grindingQuantityToleranceLowerLimit"
                              :style="{ height: '25px' }"
                              @blur="
                                handleInput2(
                                  row,
                                  $index,
                                  'grindingQuantityToleranceLowerLimit'
                                )
                              "
                            />
                          </template>
                        </el-table-column>
                      </el-table-column>

                      <el-table-column label="粗糙度" width="240" align="center">
                        <el-table-column label="标准" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                              <span style="color: red; font-weight: 700">*</span>
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.roughnessStandard"
                              :style="{ height: '25px' }"
                              @blur="handleInput2(row, $index, 'roughnessStandard')"
                            />
                          </template>
                        </el-table-column>
                        <el-table-column label="公差上限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                              <span style="color: red; font-weight: 700">*</span>
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.roughnessToleranceUpperLimit"
                              @blur="
                                handleInput2(row, $index, 'roughnessToleranceUpperLimit')
                              "
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>
                        <el-table-column label="公差下限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                              <span style="color: red; font-weight: 700">*</span>
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.roughnessToleranceLowerLimit"
                              @blur="
                                handleInput2(row, $index, 'roughnessToleranceLowerLimit')
                              "
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>
                      </el-table-column>

                      <el-table-column label="横移量" width="240" align="center">
                        <el-table-column label="上限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                              <span style="color: red; font-weight: 700">*</span>
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.lateralShiftUpperLimit"
                              @blur="handleInput2(row, $index, 'lateralShiftUpperLimit')"
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>
                        <el-table-column label="下限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                              <span style="color: red; font-weight: 700">*</span>
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.lateralShiftLowerLimit"
                              @blur="handleInput2(row, $index, 'lateralShiftLowerLimit')"
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="锥高比例" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <span>{{ row.taperHeightRatio }}</span>
                        </template>
                      </el-table-column>

                      <!-- <el-table-column label="锥高比例" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.taperHeightRatio"
                            disabled
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column> -->

                      <el-table-column label="锥长" width="240" align="center">
                        <el-table-column label="标准" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.taperLengthStandard"
                              @blur="handleInput2(row, $index, 'taperLengthStandard')"
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>

                        <el-table-column label="上限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.taperLengthUpperLimit"
                              @blur="handleInput2(row, $index, 'taperLengthUpperLimit')"
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>
                        <el-table-column label="下限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.taperLengthLowerLimit"
                              @blur="handleInput2(row, $index, 'taperLengthLowerLimit')"
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="锥高" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.taperHeight"
                            @blur="handleInput2(row, $index, 'taperHeight')"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>

                      <el-table-column label="钢带宽度范围" width="240" align="center">
                        <el-table-column label="上限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.steelStripWidthUpperLimit"
                              @blur="
                                handleInput2(row, $index, 'steelStripWidthUpperLimit')
                              "
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>
                        <el-table-column label="下限" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.steelStripWidthLowerLimit"
                              @blur="
                                handleInput2(row, $index, 'steelStripWidthLowerLimit')
                              "
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column>
                      </el-table-column>
                      <el-table-column label="备注" width="500" align="left">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <!-- <el-table-column
                        label="按钮"
                        width="160"
                        align="center"
                        fixed="right"
                      >
                        <template #default="{ row, $index }">
                          <el-button
                            :style="{ height: '25px' }"
                            type="daprimarynger"
                            size="mini"
                            @click="addRowTableData2()"
                            >增行</el-button
                          >
                          <el-button
                            :style="{ height: '25px' }"
                            type="danger"
                            size="mini"
                            @click="deleteRow2(row)"
                            >删除</el-button
                          >
                        </template>
                      </el-table-column> -->
                    </el-table>
                  </el-scrollbar>
                </div>
                <div
                  id="part3"
                  v-if="!isMx"
                  style="
                    height: 210px;
                    background: rgba(0, 0, 255, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div style="font-size: 1em; font-weight: bold">更换类别</div>
                  <el-form :inline="true" :model="formMainTable">
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span> 更换方式
                      </label>
                      <el-select
                        v-model="formMainTable.replacementMethod"
                        style="width: 180px"
                        @change="handleReplacementMethodChange"
                        :disabled="isReplacementMethod"
                      >
                        <el-option label="时间" value="0"></el-option>
                        <el-option label="工艺" value="1"></el-option>
                        <el-option label="生产任务" value="2"></el-option>
                      </el-select>

                      <label class="lab" style="width: 100px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span> 周期方式
                      </label>
                      <el-select
                        v-model="formMainTable.cycleMethod"
                        style="width: 180px"
                        :readonly="true"
                        :disabled="isTypeDisabled"
                      >
                        <el-option
                          v-for="option in typeOptions"
                          :key="option.value"
                          :label="option.label"
                          :value="option.value"
                        ></el-option>

                        <!-- <el-option label="天数" value="0"></el-option>
                        <el-option label="小时" value="1"></el-option>
                        <el-option label="分钟" value="2"></el-option>
                        <el-option label="道次" value="3"></el-option>
                        <el-option label="刀次" value="4"></el-option>
                        <el-option label="次" value="5"></el-option>
                        <el-option label="产量" value="6"></el-option> -->
                      </el-select>
                    </el-form-item>
                  </el-form>

                  <el-scrollbar>
                    <el-table
                      ref="tableEle3"
                      :data="tableData3"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange3"
                      :header-cell-style="headerCellStyle1"
                      :max-height="190 + 'px'"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <el-table-column :label="columnLabel" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column>

                      <el-table-column label="是否更换" width="100" align="center">
                        <template #default="{ row, $index }">
                          <el-select
                            v-model="row.replacementFlag"
                            :style="{ height: '25px' }"
                            size="small"
                          >
                            <el-option label="否" value="0" />
                            <el-option label="是" value="1" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="工序属性" width="100" align="center">
                        <template #default="{ row, $index }">
                          <el-select
                            v-model="row.processProperty"
                            :style="{ height: '25px' }"
                            size="small"
                            :disabled="isDisabprocessProperty"
                          >
                            <el-option label="成品" value="0" />
                            <el-option label="半成品" value="1" />
                            <el-option label="成品,半成品" value="2" />
                          </el-select>
                        </template>
                      </el-table-column>
                      <el-table-column label="周期长度" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.cycleLength"
                            @blur="handleInput3(row, $index, 'cycleLength')"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="周期单位产量" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.cycleUnitOutput"
                            @blur="handleInput3(row, $index, 'cycleUnitOutput')"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="周期产量" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <span>{{ row.cycleOutput }}</span>
                        </template>
                      </el-table-column>

                      <!-- <el-table-column label="周期产量" width="100" align="center">
                          <template #header="{ column }">
                            <span>
                              {{ column.label }}
                              <span style="color: red; font-weight: 700">*</span>
                            </span>
                          </template>
                          <template #default="{ row, $index }">
                            <el-input
                              v-model="row.cycleOutput"
                              disabled
                              :style="{ height: '25px' }"
                            />
                          </template>
                        </el-table-column> -->
                      <el-table-column label="备注" align="left">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="按钮"
                        width="160"
                        align="center"
                        fixed="right"
                      >
                        <template #default="{ row, $index }">
                          <el-button
                            :style="{ height: '25px' }"
                            type="daprimarynger"
                            size="mini"
                            @click="addRowTableData3()"
                            >增行</el-button
                          >
                          <el-button
                            :style="{ height: '25px' }"
                            type="danger"
                            size="mini"
                            @click="deleteRow3(row)"
                            >删除</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-scrollbar>
                </div>
                <div
                  id="part4"
                  style="
                    height: 30px;
                    background: rgba(255, 0, 0, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-if="!isMx">
                    磨削标准工时
                  </div>
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-else>
                    标准工时
                  </div>
                  <!-- <h4 v-if="!isMx">磨削标准工时</h4>
                  <h4 v-else>标准工时</h4> -->

                  <el-form :inline="true" :model="formMainTable">
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        工时单位</label
                      >
                      <el-select v-model="formMainTable.manHourUnit" style="width: 180px">
                        <el-option label="天数" value="0"></el-option>
                        <el-option label="小时" value="1"></el-option>
                        <el-option label="分钟" value="2"></el-option>
                      </el-select>
                    </el-form-item>

                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span
                        >工时时长:</label
                      >
                      <el-input
                        style="width: 180px"
                        v-model="formMainTable.manHourDuration"
                      />
                    </el-form-item>
                  </el-form>
                </div>
                <div
                  id="part5"
                  style="
                    height: 180px;
                    background: rgba(255, 0, 0, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-if="!isMx">
                    磨削耗用人工
                  </div>
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-else>人工</div>

                  <el-scrollbar>
                    <el-table
                      ref="tableEle5"
                      :data="tableData5"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange5"
                      :header-cell-style="headerCellStyle1"
                      :max-height="170 + 'px'"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <el-table-column label="序号" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column label="岗位" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts3($index)"
                          >
                            {{ row.positionName }}
                          </div>
                        </template>
                      </el-table-column>

                      <!-- <el-table-column label="岗位" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.positionName"
                            :style="{ height: '25px' }"
                            :readonly="true"
                            @click="openEqipmentParts3($index)"
                          />
                        </template>
                      </el-table-column> -->
                      <el-table-column label="人数" width="80" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            @blur="handleInput5(row, 'personnelNumber')"
                            v-model="row.personnelNumber"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="技能要求" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.skillRequirements"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="岗位等级" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.positionRegistration"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="备注" align="left">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="按钮"
                        width="160"
                        align="center"
                        fixed="right"
                      >
                        <template #default="{ row, $index }">
                          <el-button
                            :style="{ height: '25px' }"
                            type="daprimarynger"
                            size="mini"
                            @click="addRowTableData5()"
                            >增行</el-button
                          >
                          <el-button
                            :style="{ height: '25px' }"
                            type="danger"
                            size="mini"
                            @click="deleteRow5(row)"
                            >删除</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-scrollbar>
                </div>
                <div
                  id="part6"
                  style="
                    height: 180px;
                    background: rgba(255, 0, 0, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-if="!isMx">
                    磨削耗用辅助材料
                  </div>
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-else>
                    消耗辅助材料
                  </div>

                  <el-scrollbar>
                    <el-table
                      ref="tableEle6"
                      :data="tableData6"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange6"
                      :header-cell-style="headerCellStyle1"
                      :max-height="200 + 'px'"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <el-table-column label="序号" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column label="物料编码" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts4($index)"
                          >
                            {{ row.materialCode }}
                          </div>
                        </template>
                      </el-table-column>

                      <el-table-column label="物料名称" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts4($index)"
                          >
                            {{ row.materialName }}
                          </div>
                        </template>
                      </el-table-column>

                      <el-table-column label="物料规格" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts4($index)"
                          >
                            {{ row.materialSpecification }}
                          </div>
                        </template>
                      </el-table-column>

                      <el-table-column label="计量单位" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts4($index)"
                          >
                            {{ row.measurementUnit }}
                          </div>
                        </template>
                      </el-table-column>

                      <!-- <el-table-column label="物料编码" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.materialCode"
                            :readonly="true"
                            @click="openEqipmentParts4($index)"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="物料名称" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.materialName"
                            :readonly="true"
                            @click="openEqipmentParts4($index)"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="物料规格" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.materialSpecification"
                            :readonly="true"
                            @click="openEqipmentParts4($index)"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="计量单位" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.measurementUnit"
                            :readonly="true"
                            @click="openEqipmentParts4($index)"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column> -->
                      <el-table-column label="数量" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.quantity"
                            :style="{ height: '25px' }"
                            @blur="handleInput6(row, $index, 'quantity')"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="预算科目" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.budgetAccount"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="核算科目" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.accountingSubject"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="备注" align="left">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="按钮"
                        width="160"
                        align="center"
                        fixed="right"
                      >
                        <template #default="{ row, $index }">
                          <el-button
                            :style="{ height: '25px' }"
                            type="daprimarynger"
                            size="mini"
                            @click="addRowTableData6()"
                            >增行</el-button
                          >
                          <el-button
                            :style="{ height: '25px' }"
                            type="danger"
                            size="mini"
                            @click="deleteRow6(row)"
                            >删除</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-scrollbar>
                </div>
                <div
                  id="part7"
                  style="
                    height: 180px;
                    background: rgba(255, 0, 0, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-if="!isMx">
                    磨削（自制）耗用费用项目
                  </div>
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-else>
                    消耗（自制）费用项目
                  </div>
                  <el-scrollbar>
                    <el-table
                      ref="tableEle7"
                      :data="tableData7"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange7"
                      :header-cell-style="headerCellStyle1"
                      :max-height="180 + 'px'"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <el-table-column label="序号" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column label="费用编码" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts5($index)"
                          >
                            {{ row.expenseCode }}
                          </div>
                        </template>
                      </el-table-column>

                      <el-table-column label="费用名称" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts5($index)"
                          >
                            {{ row.expenseName }}
                          </div>
                        </template>
                      </el-table-column>

                      <!-- <el-table-column label="费用编码" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.expenseCode"
                            :readonly="true"
                            @click="openEqipmentParts5($index)"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="费用名称" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.expenseName"
                            :readonly="true"
                            @click="openEqipmentParts5($index)"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column> -->
                      <el-table-column label="金额" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.amount"
                            :style="{ height: '25px' }"
                            @blur="handleInput7(row, $index, 'amount')"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="预算科目" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.budgetAccount"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="核算科目" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.accountingSubject"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="备注" align="left">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="按钮"
                        width="160"
                        align="center"
                        fixed="right"
                      >
                        <template #default="{ row, $index }">
                          <el-button
                            :style="{ height: '25px' }"
                            type="daprimarynger"
                            size="mini"
                            @click="addRowTableData7()"
                            >增行</el-button
                          >
                          <el-button
                            :style="{ height: '25px' }"
                            type="danger"
                            size="mini"
                            @click="deleteRow7(row)"
                            >删除</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-scrollbar>
                </div>
                <div
                  id="part8"
                  style="
                    height: 180px;
                    background: rgba(255, 0, 0, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-if="!isMx">
                    磨削工步设置
                  </div>
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-else>
                    步骤设置
                  </div>
                  <el-scrollbar>
                    <el-table
                      ref="tableEle8"
                      :data="tableData8"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange8"
                      :header-cell-style="headerCellStyle1"
                      :max-height="180 + 'px'"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <el-table-column label="序号" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column>

                      <el-table-column label="工步名称" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input v-model="row.stepName" :style="{ height: '25px' }" />
                        </template>
                      </el-table-column>
                      <el-table-column label="工步工时" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.stepManHour"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="岗位" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts6($index)"
                          >
                            {{ row.positionName }}
                          </div>
                        </template>
                      </el-table-column>

                      <!-- <el-table-column label="岗位" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.positionName"
                            :style="{ height: '25px' }"
                            @click="openEqipmentParts6($index)"
                          />
                        </template>
                      </el-table-column> -->
                      <el-table-column label="人数" width="80" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            @blur="handleInput6(row, $index, 'personnelNumber')"
                            v-model="row.personnelNumber"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="技能要求" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.skillRequirements"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="岗位等级" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.positionRequirements"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="备注" align="left">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="按钮"
                        width="160"
                        align="center"
                        fixed="right"
                      >
                        <template #default="{ row, $index }">
                          <el-button
                            :style="{ height: '25px' }"
                            type="daprimarynger"
                            size="mini"
                            @click="addRowTableData8()"
                            >增行</el-button
                          >
                          <el-button
                            :style="{ height: '25px' }"
                            type="danger"
                            size="mini"
                            @click="deleteRow8(row)"
                            >删除</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-scrollbar>
                </div>
                <div
                  id="part9"
                  style="
                    height: 180px;
                    background: rgba(255, 0, 0, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-if="!isMx">
                    磨削（委外）耗用费用项目
                  </div>
                  <div :style="{ fontSize: '1em', fontWeight: 'bold' }" v-else>
                    消耗（委外）费用项目
                  </div>
                  <el-scrollbar>
                    <el-table
                      ref="tableEle9"
                      :data="tableData9"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange9"
                      :header-cell-style="headerCellStyle1"
                      :max-height="180 + 'px'"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <el-table-column label="序号" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column label="费用编码" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts7($index)"
                          >
                            {{ row.expenseCode }}
                          </div>
                        </template>
                      </el-table-column>

                      <el-table-column label="费用名称" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts7($index)"
                          >
                            {{ row.expenseName }}
                          </div>
                        </template>
                      </el-table-column>

                      <!-- <el-table-column label="费用编码" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.expenseCode"
                            :style="{ height: '25px' }"
                            :readonly="true"
                            @click="openEqipmentParts7($index)"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="费用名称" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.expenseName"
                            :style="{ height: '25px' }"
                            :readonly="true"
                            @click="openEqipmentParts7($index)"
                          />
                        </template>
                      </el-table-column> -->
                      <el-table-column label="金额" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.amount"
                            :style="{ height: '25px' }"
                            @blur="handleInput7(row, $index, 'amount')"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="预算科目" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.budgetAccount"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="核算科目" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.accountingSubject"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="备注" align="left">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="按钮"
                        width="160"
                        align="center"
                        fixed="right"
                      >
                        <template #default="{ row, $index }">
                          <el-button
                            :style="{ height: '25px' }"
                            type="daprimarynger"
                            size="mini"
                            @click="addRowTableData9()"
                            >增行</el-button
                          >
                          <el-button
                            :style="{ height: '25px' }"
                            type="danger"
                            size="mini"
                            @click="deleteRow9(row)"
                            >删除</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-scrollbar>
                </div>
                <div
                  id="part10"
                  v-if="!isMx"
                  style="
                    height: 180px;
                    background: rgba(255, 0, 0, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div style="font-size: 1em; font-weight: bold">专用磨削设备设定</div>

                  <el-scrollbar>
                    <el-table
                      ref="tableEle10"
                      :data="tableData10"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange10"
                      :header-cell-style="headerCellStyle1"
                      :max-height="180 + 'px'"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <el-table-column label="序号" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column label="设备编码" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts8($index)"
                          >
                            {{ row.equipmentCode }}
                          </div>
                        </template>
                      </el-table-column>

                      <el-table-column label="设备名称" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div
                            style="height: 25px; line-height: 25px; cursor: pointer"
                            @click="openEqipmentParts8($index)"
                          >
                            {{ row.equipmentName }}
                          </div>
                        </template>
                      </el-table-column>

                      <!-- <el-table-column label="设备编码" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.equipmentCode"
                            :style="{ height: '25px' }"
                            @click="openEqipmentParts8($index)"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="设备名称" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.equipmentName"
                            :style="{ height: '25px' }"
                            @click="openEqipmentParts8($index)"
                          />
                        </template>
                      </el-table-column> -->
                      <el-table-column label="备注" align="center">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="按钮"
                        width="160"
                        align="center"
                        fixed="right"
                      >
                        <template #default="{ row, $index }">
                          <el-button
                            :style="{ height: '25px' }"
                            type="daprimarynger"
                            size="mini"
                            @click="addRowTableData10()"
                            >增行</el-button
                          >
                          <el-button
                            :style="{ height: '25px' }"
                            type="danger"
                            size="mini"
                            @click="deleteRow10(row)"
                            >删除</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-scrollbar>
                </div>
                <div
                  id="part11"
                  v-if="!isMx"
                  style="
                    height: 180px;
                    background: rgba(255, 0, 0, 0.02);
                    margin-top: 30px;
                  "
                >
                  <div style="font-size: 1em; font-weight: bold">专用磨削班组</div>

                  <el-form :model="formSubTable11" :inline="true">
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        班组编码</label
                      >
                      <el-input
                        style="width: 180px"
                        v-model="formSubTable11.teamCode"
                        @click="openEqipmentParts9($index)"
                        :readonly="true"
                        clearable
                      />
                    </el-form-item>
                    <el-form-item class="labs" style="margin-right: 0">
                      <label class="lab" style="width: 100px; padding-right: 5px">
                        <span style="color: red; font-weight: 700">*</span>
                        班组名称</label
                      >
                      <el-input
                        style="width: 180px"
                        v-model="formSubTable11.teamName"
                        @click="openEqipmentParts9($index)"
                        :readonly="true"
                        clearable
                      />
                    </el-form-item>
                  </el-form>
                  <el-scrollbar>
                    <el-table
                      ref="tableEle11"
                      :data="tableData11"
                      stripe
                      border
                      :row-style="{ height: '20px' }"
                      style="width: 100%"
                      :cell-style="cellStyle1"
                      @selection-change="handleSelectionChange11"
                      :header-cell-style="headerCellStyle1"
                      :max-height="180 + 'px'"
                    >
                      <!-- <el-table-column type="selection" width="55" align="center" /> -->
                      <el-table-column label="序号" width="80" align="center">
                        <template #default="{ $index }">
                          <span>{{ $index + 1 }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column label="员工工号" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div style="height: 25px; line-height: 25px">
                            {{ row.employeeID }}
                          </div>
                        </template>
                      </el-table-column>

                      <el-table-column label="员工姓名" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <div style="height: 25px; line-height: 25px">
                            {{ row.employeeName }}
                          </div>
                        </template>
                      </el-table-column>

                      <!-- <el-table-column label="员工工号" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.employeeID"
                            disabled
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column label="员工姓名" width="100" align="center">
                        <template #header="{ column }">
                          <span>
                            {{ column.label }}
                            <span style="color: red; font-weight: 700">*</span>
                          </span>
                        </template>
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.employeeName"
                            disabled
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column> -->
                      <el-table-column label="备注" align="center">
                        <template #default="{ row, $index }">
                          <el-input
                            v-model="row.description"
                            :style="{ height: '25px' }"
                          />
                        </template>
                      </el-table-column>
                      <el-table-column
                        label="按钮"
                        width="160"
                        align="center"
                        fixed="right"
                      >
                        <template #default="{ row, $index }">
                          <el-button
                            :style="{ height: '25px' }"
                            type="daprimarynger"
                            size="mini"
                            @click="addRowTableData11()"
                            >增行</el-button
                          >
                          <el-button
                            :style="{ height: '25px' }"
                            type="danger"
                            size="mini"
                            @click="deleteRow11(row)"
                            >删除</el-button
                          >
                        </template>
                      </el-table-column>
                    </el-table>
                  </el-scrollbar>
                </div>
              </div>
            </el-col>
          </el-row>
        </div>
      </el-scrollbar>
    </div>
  </div>
  <!-- 页面布局 -->
  <div>
    <el-container>
      <el-header height="65px" :style="{ 'border-bottom': '1px solid #ccc' }">
        <!-- 头部按钮 -->
        <el-row type="flex" justify="end" style="background-color: rgb(211, 227, 253)">
          <div>
            <el-button @click="searchButton" type="primary"> 查询</el-button>
            <el-button @click="openInseart" type="success"> 新增</el-button>
            <el-button @click="handleWarning0" type="warning">审核</el-button>
            <el-button @click="handleWarning1" type="danger">弃审</el-button>
            <el-button @click="handleDelete" type="danger">删除</el-button>
          </div>
          <!-- <div class="title">需求汇总统计表</div> -->
        </el-row>
        <div
          style="margin-left:6rem;height: 30px;width=100%; background:rgb(241,244,243);margin-bottom: 0;position: relative; display: flex; justify-content: flex-start;"
        >
          <el-input
            style="width: 10%; height: 25px; margin-left: 2px; margin-top: 2px"
            v-model="equipmentStructureInput"
            placeholder="结构编号"
          >
            <template #prefix>
              <el-icon class="">
                <search />
              </el-icon>
            </template>
          </el-input>
          <el-input
            style="width: 10%; height: 25px; margin-left: 2px; margin-top: 2px"
            v-model="structureNameInput"
            placeholder="结构名称"
          >
            <template #prefix>
              <el-icon class="">
                <search />
              </el-icon>
            </template>
          </el-input>
          <el-input
            style="width: 10%; height: 25px; margin-left: 2px; margin-top: 2px"
            v-model="nameInput"
            placeholder="设备零件"
          >
            <template #prefix>
              <el-icon class="">
                <search />
              </el-icon>
            </template>
          </el-input>
          <!-- <el-input
          style="width: 10%; height: 25px; margin-left: 2px; margin-top: 2px"
          v-model="standardType"
          placeholder="标准类型"
        >
          <template #prefix>
            <el-icon class="">
              <search />
            </el-icon>
          </template>
        </el-input> -->
          <el-select
            style="width: 10%; height: 25px; margin-left: 2px; margin-top: 2px"
            v-model="standardTypeInput"
            placeholder="标准类型"
            clearable
            size="small"
          >
            <el-option label="通用标准" value="0"></el-option>
            <el-option label="专用标准" value="1"></el-option>
          </el-select>
          <el-select
            style="width: 10%; height: 25px; margin-left: 2px; margin-top: 2px"
            clearable
            size="small"
            v-model="proceduresInput"
            :readonly="true"
          >
            <el-option label="轧机" value="0"></el-option>
            <el-option label="退火" value="1"></el-option>
            <el-option label="拉矫" value="2"></el-option>
            <el-option label="分条" value="3"></el-option>
            <el-option label="清洗线" value="4"></el-option>
            <el-option label="破带" value="5"></el-option>
            <el-option label="大分条" value="6"></el-option>
            <el-option label="去应力" value="7"></el-option>
            <el-option label="贴膜" value="8"></el-option>
            <el-option label="研磨" value="9"></el-option>
          </el-select>
        </div>
      </el-header>
      <el-container>
        <el-container>
          <el-main style="padding: 2px 2px 0 2px; margin-left: 6rem">
            <el-table
              v-loading="loading"
              ref="table"
              :data="tableData"
              border
              stripe
              :cell-style="cellStyle"
              :header-cell-style="headerCellStyle"
              @selection-change="handleSelectionChange"
              @row-dblclick="handleRowClick"
              @row-click="RowClick"
              :row-style="rowState"
              :row-key="(row:any) => row.id"
              :max-height="screenHeight"
              :height="screenHeight"
            >
              <el-table-column fixed type="index" width="80" align="center" />
              <el-table-column fixed type="selection" width="50" align="center" />
              <!-- <el-table-column prop="id" label="ID" width="70" align="center" /> -->
              <el-table-column
                prop="processCode"
                label="标准编号"
                width="80"
                align="center"
              />
              <el-table-column
                prop="processName"
                label="标准名称"
                width="280"
                align="left"
              />

              <el-table-column prop="name" label="设备零件" width="140" align="center" />1

              <el-table-column
                prop="structureName"
                label="设备结构"
                width="120"
                align="center"
              />
              <el-table-column
                prop="consumableCategoryName"
                label="耗材类别"
                width="120"
                align="center"
              />
              <el-table-column prop="model" label="型号" width="120" align="center" />

              <el-table-column
                prop="standardType"
                label="标准类型"
                width="120"
                align="center"
              />
              <el-table-column prop="type" label="类型" width="120" align="center" />
              <el-table-column prop="model" label="型号" width="120" align="center" />
              <el-table-column
                prop="proceduresName"
                label="工序"
                width="120"
                align="center"
              />
              <el-table-column
                prop="processPropertyName"
                label="工序属性"
                width="120"
                align="center"
              />
              <el-table-column
                prop="passToolNumber"
                label="磨削道次数"
                width="80"
                align="center"
              />
              <el-table-column
                prop="productPurposeName"
                label="产品用途"
                width="80"
                align="center"
              />
              <el-table-column
                prop="materialName"
                label="材质"
                width="80"
                align="center"
              />
              <el-table-column prop="creator" label="创建人" width="120" align="center" />
              <el-table-column
                prop="reviewer"
                label="审核人"
                width="120"
                align="center"
              />
              <el-table-column
                prop="modifier"
                label="修改人"
                width="120"
                align="center"
              />
              <el-table-column prop="stateName" label="状态" width="120" align="center" />
            </el-table>
          </el-main>
          <el-footer style="height: 20px">
            <div class="demo-pagination-block">
              <el-pagination
                v-model:current-page="page"
                v-model:page-size="limit"
                :page-sizes="[50, 500, 1000, 1500, 2000, 8000]"
                :small="true"
                :background="true"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
              />
            </div>
          </el-footer>
        </el-container>
      </el-container>
    </el-container>
  </div>
  <SearchTableDialog
    ref="sed"
    @row-data="handleRowData"
    @row-datas="handleRowDatas"
  ></SearchTableDialog>
  <!-- 用途 -->
  <SearchTableDialog
    ref="sea"
    @row-data="handleRowData1"
    @row-datas="handleRowDatas1"
  ></SearchTableDialog>
  <!-- 材质 -->
  <SearchTableDialog
    ref="seb"
    @row-data="handleRowData2"
    @row-datas="handleRowDatas2"
  ></SearchTableDialog>
  <!-- 岗位 -->
  <SearchTableDialog
    ref="sec"
    @row-data="handleRowData3"
    @row-datas="handleRowDatas3"
  ></SearchTableDialog>
  <!-- k3编码 -->
  <SearchTableDialog
    ref="see"
    @row-data="handleRowData4"
    @row-datas="handleRowDatas4"
  ></SearchTableDialog>
  <!-- 费用项目 -->
  <SearchTableDialog
    ref="sef"
    @row-data="handleRowData5"
    @row-datas="handleRowDatas5"
  ></SearchTableDialog>
  <!-- 工步岗位 -->
  <SearchTableDialog
    ref="seg"
    @row-data="handleRowData6"
    @row-datas="handleRowDatas6"
  ></SearchTableDialog>
  <!-- 委外项目 -->
  <SearchTableDialog
    ref="seh"
    @row-data="handleRowData7"
    @row-datas="handleRowDatas7"
  ></SearchTableDialog>
  <!-- 专用设备 -->
  <SearchTableDialog
    ref="sei"
    @row-data="handleRowData8"
    @row-datas="handleRowDatas8"
  ></SearchTableDialog>
  <!-- 专用班组 -->
  <SearchTableDialog
    ref="sej"
    @row-data="handleRowData9"
    @row-datas="handleRowDatas9"
  ></SearchTableDialog>
</template>
<script setup lang="ts">
import {
  ref,
  watch,
  reactive,
  onMounted,
  onBeforeMount,
  computed,
  nextTick,
  onUnmounted,
  toRefs,
} from "vue";
import { Delete, Edit, Search, Share, Upload, Calendar } from "@element-plus/icons-vue";
import {
  ElButton,
  ElDialog,
  dialogEmits,
  ElMessage,
  ElTable,
  TableColumnCtx,
  ElMessageBox,
} from "element-plus";
import { formatNumberToCurrency } from "@/utils/formatUtils";
import type { FormInstance, FormRules } from "element-plus";
import { CircleCloseFilled } from "@element-plus/icons-vue";
import { useRouter } from "vue-router";
import axios from "../../axios/axiosInstance.ts";
import Cookies from "js-cookie";
import { format } from "date-fns";
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
// crud封装组件
import * as crud from "../../components/utils/crud.ts";
import SearchTableDialog from "@/components/dialogs/SearchTableDialog.vue";
import * as notifications from "../../components/utils/notification.ts";

const router = useRouter();
const dialogTableVisible = ref(false);
const loading = ref(false);
// 分页
const page = ref(1);
const limit = ref(50);
const total = ref(50);
const isMx = ref(false);
const equipmentStructureInput = ref("");
const structureNameInput = ref("");
const nameInput = ref("");
const standardTypeInput = ref("");
const proceduresInput = ref("");
const selectBusinessDate = computed(() => ({
  page: page.value,
  limit: limit.value,
  equipmentStructure: equipmentStructureInput.value,
  structureName: structureNameInput.value,
  name: nameInput.value,
  standardType: standardTypeInput.value,
  procedures: proceduresInput.value,
}));
const selectPermissionsButton = async () => {
  loading.value = true;
  try {
    const res = await crud.fetchData(
      "/Gri/select/GrindingProcessStandardMain",
      "post",
      selectBusinessDate.value
    );
    console.log(res);
    if (res.length == 0) {
      total.value = 0;
      tableData.value = [];
      loading.value = false;
      return;
    }
    const definitionsList = res;
    total.value = definitionsList[0].total;
    loading.value = false;

    tableData.value = definitionsList.map((item: any) => ({
      consumableCategoryName:
        item.consumableCategory === 0
          ? "辊轴类"
          : item.consumableCategory === 1
          ? "刀具类"
          : item.consumableCategory === 2
          ? "隔套类"
          : item.consumableCategory === 3
          ? "辊箱"
          : item.consumableCategory === 4
          ? "刀轴"
          : "其他",

      // stateName: item.state == 0 ? "待审核" : item.state == 1 ? "已审核" : "其他",
      stateName: 1,

      ...item,
    }));
  } catch (error) {
    loading.value = false;
    console.error("请求失败:", error);
  }
};
selectPermissionsButton();

// 计算高度
const screenHeight = ref(null);
const screenWidth = ref(null);
const childTableHeight = ref(null);
const dynamicHeight = ref(null);
const scollbarHeight = ref(null);

const getScreenHeight = () => {
  screenHeight.value = window.innerHeight - 146 - 42 + 55;
  childTableHeight.value = window.innerHeight;
  screenWidth.value = window.innerWidth;
  dynamicHeight.value = `${window.innerHeight}`;
  scollbarHeight.value = `${window.innerHeight}` - 231;
};
getScreenHeight();

const handleSizeChange = (val: number) => {
  selectPermissionsButton();
};
const handleCurrentChange = (val: number) => {
  selectPermissionsButton();
};
// 头部按钮
// 搜索框
const inputId = ref("");
const inputfabh = ref("");

const searchButton = async () => {
  selectPermissionsButton();
};
//删除
const requestDataAsid = computed(() => {
  const creationTime = getCurrentFormattedDateTime();
  const userName = Cookies.get("userName");

  return {
    deleteIdList: selectedRows.value,
    creationTime: creationTime,
    userName: userName,
    state: 0,
  };
});

// handleWarning0
const handleWarning0 = async () => {
  try {
    const result = await notifications.showConfirmDialog("", "请确认审核", "success");
    if (result) {
      if (selectedRows.value.length === 0) {
        notifications.showMessage("请至少选择一行进行操作", "error");
        return;
      }
      requestDataAsid.value.state = 1;
      const res = await crud.sendRequest(
        "/Gri/update/Sh/GrindingProcessStandardMain",
        "post",
        requestDataAsid.value
      );
      selectPermissionsButton();
    }
  } catch (error) {
    console.error("审核失败:", error);
  }
};
const handleWarning1 = async () => {
  try {
    const result = await notifications.showConfirmDialog("", "请确认审核", "success");
    if (result) {
      if (selectedRows.value.length === 0) {
        notifications.showMessage("请至少选择一行进行操作", "error");
        return;
      }
      requestDataAsid.value.state = 0;
      const res = await crud.sendRequest(
        "/Gri/update/Sh/GrindingProcessStandardMain",
        "post",
        requestDataAsid.value
      );
      selectPermissionsButton();
    }
  } catch (error) {
    console.error("审核失败:", error);
  }
};
const handleDelete = async () => {
  try {
    const result = await notifications.showConfirmDialog("", "请确认删除", "success");
    if (result) {
      if (selectedRows.value.length === 0) {
        notifications.showMessage("请至少选择一行进行操作", "error");
        return;
      }

      const res = await crud.sendRequest(
        "/Gri/delete/GrindingProcessStandardMain",
        "post",
        requestDataAsid.value
      );
      selectPermissionsButton();
    }
  } catch (error) {
    console.error("请求失败:", error);
  }
};

// 新增页面

// 主表

// 定义前端数据模型
const formMainTable = ref({
  id: "",
  processCode: "",
  processName: "",
  standardType: "0", // 标准类型
  state: "", // 状态
  equipmentParts: "", // 设备零件
  name: "", //零件的名称
  equipmentStructure: "", // 设备结构
  structureName: "", //设备名称
  consumableCategory: "", // 耗材类别
  consumableCategoryName: "", //耗材类别名称
  model: "", // 型号
  modelName: "", //型号名称
  productPurpose: "", // 产品用途ID
  productPurposeName: "", //产品用途名称
  material: "", // 材质
  materialName: "", // 材质名称
  procedures: "", //工序
  processProperty: "0", // 工序属性
  passToolNumber: 0, // 道次/刀数
  standardDetails: "", //标准详述
  finishedThickness: "", // 成品厚度
  finishedWidth: "", // 成品宽度
  hardnessRange: "", // 硬度范围
  elongationRange: "", // 延伸率范围
  surfaceRoughnessRange: "", // 成品粗糙度范围
  tensileRange: "", // 抗拉范围
  hardenabilityRange: "", // 硬化系数范围
  tiElementRange: "", // Ti元素范围
  taElementRange: "", // Ta元素范围
  nbElementRange: "", // Nb元素范围
  alElementRange: "", // Al元素范围
  zrElementRange: "", // Zr元素范围
  uElementRange: "", // U元素范围
  bElementRange: "", // B元素范围
  feElementRange: "", // Fe元素范围
  coElementRange: "", // Co元素范围
  wElementRange: "", // W元素范围
  hElementRange: "", // H元素范围
  oElementRange: "", // O元素范围
  cElementRange: "", // C元素范围
  siElementRange: "", // Si元素范围
  mnElementRange: "", // Mn元素范围
  pElementRange: "", // P元素范围
  sElementRange: "", // S元素范围
  crElementRange: "", // Cr元素范围
  niElementRange: "", // Ni元素范围
  moElementRange: "", // Mo元素范围
  cuElementRange: "", // Cu元素范围
  nElementRange: "", // N元素范围
  cycleMethod: "", // 周期方式
  replacementMethod: "", // 更换方式
  manHourUnit: "0", // 工时单位
  manHourDuration: "", // 工时时长
  type: "0", // 类型
  creator: "", //创建者
  creatorID: "", // 创建者ID
  creationTime: "", // 创建时间
  reviewer: "", // 审核者
  reviewerID: "", // 审核者ID
  reviewTime: "", // 审核时间
  modifier: "", // 修改者
  modifierID: "", // 修改者ID
  modificationTime: "", // 修改时间
  explain: "", //说明
});

const showInsertButton = ref(true);
const updateStandardDetails = () => {
  const {
    processCode, //标准编号
    processName, //标准名称
    standardType, //标准类型
    name,
    structureName,
    consumableCategoryName,
    model,
    productPurposeName,
    materialName,
    processProperty,
    passToolNumber,
    type,
  } = formMainTable.value;
  const standardTypeLabel = standardType == "0" ? "通用标准" : "专用标准";
  const typeLabel = type == "0" ? "磨削标准" : type == "1" ? "安装标准" : "拆卸标准";
  const processPropertyLabel =
    processProperty === "0"
      ? "——————"
      : processProperty === "1"
      ? "压延成品"
      : processProperty === "2"
      ? "压延半成品"
      : processProperty === "3"
      ? "分条成品"
      : "分条半成品";

  formMainTable.value.standardDetails = `${processCode}-${processName}-${typeLabel}-${standardTypeLabel}-${name}-${structureName}-${consumableCategoryName}-${model}-${productPurposeName}-${materialName}-${processPropertyLabel}-${passToolNumber}`;
};

watch(formMainTable, updateStandardDetails, { deep: true });
// const standardDetails = computed(() => {
//   const {
//     processCode,
//     processName,
//     standardType,
//     state,
//     equipmentParts,
//     name,
//     equipmentStructure,
//     structureName,
//     consumableCategory,
//     consumableCategoryName,
//     model,
//     productPurpose,
//     productPurposeName,
//     material,
//     materialName,
//     processProperty,
//     passToolNumber,
//   } = formMainTable.value;

//   return `${processCode}-${processName}-${standardType}-${state}-${equipmentParts}-${name}-${equipmentStructure}-${structureName}-${consumableCategory}-${consumableCategoryName}-${model}-${productPurpose}-${productPurposeName}-${material}-${materialName}-${processProperty}-${passToolNumber}`;
// });

//折叠：
const activeNames = ref([""]);
const dynamicTitle = ref("展开参数");
const collapsed = ref(48);
const affixOffset = ref(250);

const handleChange = (val: string[]) => {
  if (dynamicTitle.value == "折叠参数") {
    dynamicTitle.value = "展开参数";
    //  scollbarHeight.value = 724;
    scollbarHeight.value = `${window.innerHeight}` - 231;
    collapsed.value = 48;
    affixOffset.value = 250;
    return;
  }
  dynamicTitle.value = "折叠参数";
  affixOffset.value = 500;
  //   scollbarHeight.value = 472;
  scollbarHeight.value = `${window.innerHeight}` - 483;
  collapsed.value = 300;
  return;
};
// 锚点
const formInline = reactive({
  user: "",
  region: "",
  date: "",
});

const onSubmit = () => {
  console.log("submit!");
};
const containerRef = ref<HTMLElement | null>(null);
const containerHeight = ref(window.innerHeight);
const handleChangeAnchor = (href: string) => {
  // scrollTo
  //   scrollTo("#part1");
  console.log(`anchor change: ${href}`);
};
const links = computed(() => {
  switch (formMainTable.value.type) {
    case "0":
      return [
        { id: "part1", href: "#part1", title: "技术标准" },
        { id: "part2", href: "#part2", title: "磨削道次" },
        { id: "part3", href: "#part3", title: "更换类别" },
        { id: "part4", href: "#part4", title: "磨削标准工时" },
        { id: "part5", href: "#part5", title: "磨削耗用人工" },
        { id: "part6", href: "#part6", title: "磨削耗用辅助材料" },
        { id: "part7", href: "#part7", title: "磨削（自制）耗用费用项目" },
        { id: "part8", href: "#part8", title: "磨削工步设置" },
        { id: "part9", href: "#part9", title: "磨削（委外）耗用费用项目" },
        { id: "part10", href: "#part10", title: "专用磨削设备设定" },
        { id: "part11", href: "#part11", title: "专用磨削班组" },
      ];

    default:
      return [
        { id: "part4", href: "#part4", title: "标准工时" },
        { id: "part5", href: "#part5", title: "人工" },
        { id: "part6", href: "#part6", title: "消耗辅助材料" },
        { id: "part7", href: "#part7", title: "消耗（自制）费用项目" },
        { id: "part8", href: "#part8", title: "步骤设置" },
        { id: "part9", href: "#part9", title: "消耗（委外）费用项目" },
      ];
  }

  //   { id: "part1", href: "#part1", title: "技术标准" },
  //   { id: "part2", href: "#part2", title: "磨削道次" },
  //   { id: "part3", href: "#part3", title: "更换类别" },
  //   { id: "part4", href: "#part4", title: "磨削标准工时" },
  //   { id: "part5", href: "#part5", title: "磨削耗用人工" },
  //   { id: "part6", href: "#part6", title: "磨削耗用辅助材料" },
  //   { id: "part7", href: "#part7", title: "磨削（自制）耗用费用项目" },
  //   { id: "part8", href: "#part8", title: "磨削工步设置" },
  //   { id: "part9", href: "#part9", title: "磨削（委外）耗用费用项目" },
  //   { id: "part10", href: "#part10", title: "专用磨削设备设定" },
  //   { id: "part11", href: "#part11", title: "专用磨削班组" },
});
onMounted(() => {
  const updateContainerHeight = () => {
    containerHeight.value = window.innerHeight;
  };

  window.addEventListener("resize", updateContainerHeight);
  // 当组件销毁时，记得移除事件监听器
  onUnmounted(() => {
    window.removeEventListener("resize", updateContainerHeight);
  });
});
// Main表格
const defaultRowData1 = {
  id: "",
  project: "", //项目
  standard: "", //标准
  toleranceLowerLimit: "", //公差下限
  toleranceUpperLimit: "", //公差上限
  valueRangeType: "0", //值域类型
  description: "", //备注
  isDisabled: true,
  isDisabled0: false,
};
const defaultRowData2 = {
  id: "",
  grindingQuantityStandard: "",
  grindingQuantityToleranceLowerLimit: "",
  grindingQuantityToleranceUpperLimit: "",
  roughnessStandard: "",
  roughnessToleranceLowerLimit: "",
  roughnessToleranceUpperLimit: "",
  lateralShiftLowerLimit: "",
  lateralShiftUpperLimit: "",
  taperHeightRatio: "",
  taperLengthStandard: "",
  taperLengthLowerLimit: "",
  taperLengthUpperLimit: "",
  taperHeight: "",
  steelStripWidthLowerLimit: "",
  steelStripWidthUpperLimit: "",
  description: "", //备注
};
const defaultRowData3 = {
  id: "",
  replacementFlag: "1", //是否更换
  processProperty: "1", //工序属性
  cycleLength: "", //周期长度
  cycleUnitOutput: 0, //周期单位产量
  cycleOutput: 0, //周期产量
  description: "", //备注
};
const defaultRowData5 = {
  id: "",
  position: "", //岗位
  positionName: "", //岗位名称
  personnelNumber: "", //人数
  skillRequirements: "", //技能要求
  positionRegistration: "", //岗位登记
  description: "", //备注
};
const defaultRowData6 = {
  id: "",
  materialCode: "", //物料编码
  materialName: "", //物料名称
  materialSpecification: "", //物料规格
  measurementUnit: "", //计量单位
  quantity: "", //数量
  budgetAccount: "", //预算科目
  accountingSubject: "", //核算科目
  description: "", //备注
};
const defaultRowData7 = {
  id: "",
  expenseCode: "", //费用编码
  expenseName: "", //费用名称
  amount: "", //金额
  budgetAccount: "", //预算科目
  accountingSubject: "", //核算科目
  description: "", //备注
};
const defaultRowData8 = {
  id: "",
  stepName: "", //工步名称
  stepManHour: "", //工步工时
  position: "", //岗位
  positionName: "", //岗位
  personnelNumber: "", //人数
  skillRequirements: "", //技能要求
  positionRegistration: "", //岗位等级
  description: "", //备注
};
const defaultRowData9 = {
  id: "",
  expenseCode: "", //费用编码
  expenseName: "", //费用名称
  amount: "", //金额
  budgetAccount: "", //预算科目
  accountingSubject: "", //核算科目
  description: "", //备注
};
const defaultRowData10 = {
  id: "",
  equipmentCode: "", //设备编码
  equipmentName: "", //设备名称
  description: "", //备注
};
const defaultRowData11 = {
  id: "",
  employeeID: "", //员工工号
  employeeName: "", //员工姓名
  description: "", //备注
};

const selectedRows = ref([]);
const selectedRows1 = ref([]);
const selectedRows2 = ref([]);
const selectedRows3 = ref([]);
// const selectedRows4 = ref([]);
const selectedRows5 = ref([]);
const selectedRows6 = ref([]);
const selectedRows7 = ref([]);
const selectedRows8 = ref([]);
const selectedRows9 = ref([]);
const selectedRows10 = ref([]);
const table = ref();
const tableEle1 = ref();
const tableEle2 = ref();
const tableEle3 = ref();
// const tableEle4 = ref();
const tableEle5 = ref();
const tableEle6 = ref();
const tableEle7 = ref();
const tableEle8 = ref();
const tableEle9 = ref();
const tableEle10 = ref();
const tableEle11 = ref();
const tableData = ref([]);
const tableData1 = ref([]);
const tableData2 = ref([]);
const tableData3 = ref([]);
// const tableData4 = ref([]);
const tableData5 = ref([]);
const tableData6 = ref([]);
const tableData7 = ref([]);
const tableData8 = ref([]);
const tableData9 = ref([]);
const tableData10 = ref([]);
const tableData11 = ref([]);
const openInseart = () => {
  dialogTableVisible.value = true;
  showInsertButton.value = true;
  isDisabledleri.value = true;
  isReplacementMethod.value = true;
  for (let i = 0; i < 8; i++) {
    const rowData = { ...defaultRowData1 };
    rowData.project = String(i); // 将数字转换为字符串
    tableData1.value.push(rowData);
  }

  for (let i = 0; i < 5; i++) {
    const rowData3 = { ...defaultRowData3 };

    tableData3.value.push(rowData3);
  }

  for (let i = 0; i < 5; i++) {
    const rowData5 = { ...defaultRowData5 };

    tableData5.value.push(rowData5);
  }
  for (let i = 0; i < 5; i++) {
    const rowData6 = { ...defaultRowData6 };

    tableData6.value.push(rowData6);
  }
  for (let i = 0; i < 5; i++) {
    const rowData7 = { ...defaultRowData7 };

    tableData7.value.push(rowData7);
  }
  for (let i = 0; i < 5; i++) {
    const rowData8 = { ...defaultRowData8 };

    tableData8.value.push(rowData8);
  }
  for (let i = 0; i < 5; i++) {
    const rowData9 = { ...defaultRowData9 };

    tableData9.value.push(rowData9);
  }
  for (let i = 0; i < 5; i++) {
    const rowData10 = { ...defaultRowData10 };

    tableData10.value.push(rowData10);
  }
  for (let i = 0; i < 5; i++) {
    const rowData11 = { ...defaultRowData11 };

    tableData11.value.push(rowData11);
  }
};

const formSubTable11 = ref({
  id: "",
  teamCode: "", // 班组编码
  teamName: "", // 班组名称
});

const OFFdialogTableVisible = () => {
  dialogTableVisible.value = false;
  isDisabledleri.value = true;
  tableData1.value = [];
  tableData2.value = [];
  tableData3.value = [];
  // const tableData4 = ref([]);
  tableData5.value = [];
  tableData6.value = [];
  tableData7.value = [];
  tableData8.value = [];
  tableData9.value = [];
  tableData10.value = [];
  tableData11.value = [];
  selectPermissionsButton();

  // 工艺编号，默认为空字符串
  formMainTable.value.processCode = "";
  // 工艺名称，默认为空字符串
  formMainTable.value.processName = "";

  // 标准类型，默认值为 "0"
  formMainTable.value.standardType = "0";

  // 状态，默认为空字符串
  formMainTable.value.state = "";

  // 设备零件，默认为空字符串
  formMainTable.value.equipmentParts = "";

  // 零件的名称，默认为空字符串
  formMainTable.value.name = "";

  // 设备结构，默认为空字符串
  formMainTable.value.equipmentStructure = "";

  // 设备名称，默认为空字符串
  formMainTable.value.structureName = "";

  // 耗材类别，默认为空字符串
  formMainTable.value.consumableCategory = "";

  // 耗材类别名称，默认为空字符串
  formMainTable.value.consumableCategoryName = "";

  // 型号，默认为空字符串
  formMainTable.value.model = "";
  //型号名称
  formMainTable.value.modelName = "";

  // 产品用途ID，默认为空字符串
  formMainTable.value.productPurpose = "";

  // 产品用途名称，默认为空字符串
  formMainTable.value.productPurposeName = "";

  // 材质，默认为空字符串
  formMainTable.value.material = "";

  // 材质名称，默认为空字符串
  formMainTable.value.materialName = "";
  //工序
  formMainTable.value.procedures = "0";

  // 工序属性，默认值为 "0"
  formMainTable.value.processProperty = "0";

  // 道次/刀数，默认值为 0
  formMainTable.value.passToolNumber = 0;

  //说明,默认为空
  formMainTable.value.explain = "";

  // 成品厚度，默认为0.0
  formMainTable.value.finishedThickness = 0.0;

  // 成品宽度，默认值为 0.0
  formMainTable.value.finishedWidth = 0.0;

  // 硬度范围，默认为空字符串
  formMainTable.value.hardnessRange = "";

  // 延伸率范围，默认为空字符串
  formMainTable.value.elongationRange = "";

  // 成品粗糙度范围，默认为空字符串
  formMainTable.value.surfaceRoughnessRange = "";

  // 抗拉范围，默认为空字符串
  formMainTable.value.tensileRange = "";

  // 硬化系数范围，默认为空字符串
  formMainTable.value.hardenabilityRange = "";

  // Ti元素范围，默认为空字符串
  formMainTable.value.tiElementRange = "";

  // Ta元素范围，默认为空字符串
  formMainTable.value.taElementRange = "";

  // Nb元素范围，默认为空字符串
  formMainTable.value.nbElementRange = "";

  // Al元素范围，默认为空字符串
  formMainTable.value.alElementRange = "";

  // Zr元素范围，默认为空字符串
  formMainTable.value.zrElementRange = "";

  // U元素范围，默认为空字符串
  formMainTable.value.uElementRange = "";

  // B元素范围，默认为空字符串
  formMainTable.value.bElementRange = "";

  // Fe元素范围，默认为空字符串
  formMainTable.value.feElementRange = "";

  // Co元素范围，默认为空字符串
  formMainTable.value.coElementRange = "";

  // W元素范围，默认为空字符串
  formMainTable.value.wElementRange = "";

  // H元素范围，默认为空字符串
  formMainTable.value.hElementRange = "";

  // O元素范围，默认为空字符串
  formMainTable.value.oElementRange = "";

  // C元素范围，默认为空字符串
  formMainTable.value.cElementRange = "";

  // Si元素范围，默认为空字符串
  formMainTable.value.siElementRange = "";

  // Mn元素范围，默认为空字符串
  formMainTable.value.mnElementRange = "";

  // P元素范围，默认为空字符串
  formMainTable.value.pElementRange = "";

  // S元素范围，默认为空字符串
  formMainTable.value.sElementRange = "";

  // Cr元素范围，默认为空字符串
  formMainTable.value.crElementRange = "";

  // Ni元素范围，默认为空字符串
  formMainTable.value.niElementRange = "";

  // Mo元素范围，默认为空字符串
  formMainTable.value.moElementRange = "";

  // Cu元素范围，默认为空字符串
  formMainTable.value.cuElementRange = "";

  // N元素范围，默认为空字符串
  formMainTable.value.nElementRange = "";

  // 周期方式，默认值为 "0"
  formMainTable.value.cycleMethod = "0";

  // 更换方式，默认值为 "0"
  formMainTable.value.replacementMethod = "0";

  // 工时单位，默认值为 "0"
  formMainTable.value.manHourUnit = "0";

  // 工时时长，默认为空字符串
  formMainTable.value.manHourDuration = "";

  // 类型，默认值为 "0"
  formMainTable.value.type = "0";
};
const handleSelectionChange = (selection: any) => {
  selectedRows.value = selection;
};
const handleSelectionChange1 = (selection: any) => {
  selectedRows1.value = selection;
};
const handleSelectionChange2 = (selection: any) => {
  selectedRows2.value = selection;
};
const handleSelectionChange3 = (selection: any) => {
  selectedRows3.value = selection;
};
// const handleSelectionChange4 = (selection: any) => {
//   selectedRows4.value = selection;
// };
const handleSelectionChange5 = (selection: any) => {
  selectedRows5.value = selection;
};
const handleSelectionChange6 = (selection: any) => {
  selectedRows6.value = selection;
};
const handleSelectionChange7 = (selection: any) => {
  selectedRows7.value = selection;
};
const handleSelectionChange8 = (selection: any) => {
  selectedRows8.value = selection;
};
const handleSelectionChange9 = (selection: any) => {
  selectedRows9.value = selection;
};
const handleSelectionChange10 = (selection: any) => {
  selectedRows10.value = selection;
};
const handleSelectionChange11 = (selection: any) => {
  selectedRows11.value = selection;
};
const addRowTableData2 = () => {
  tableData2.value.push({
    ...defaultRowData2,
  });
};
const addRowTableData3 = () => {
  tableData3.value.push({
    ...defaultRowData3,
  });
};
// const addRowTableData4 = () => {
//   tableData4.value.push({
//     ...defaultRowData4,
//   });
// };
const addRowTableData5 = () => {
  tableData5.value.push({
    ...defaultRowData5,
  });
};
const addRowTableData6 = () => {
  tableData6.value.push({
    ...defaultRowData6,
  });
};
const addRowTableData7 = () => {
  tableData7.value.push({
    ...defaultRowData7,
  });
};
const addRowTableData8 = () => {
  tableData8.value.push({
    ...defaultRowData8,
  });
};
const addRowTableData9 = () => {
  tableData9.value.push({
    ...defaultRowData9,
  });
};
const addRowTableData10 = () => {
  tableData10.value.push({
    ...defaultRowData10,
  });
};
const addRowTableData11 = () => {
  tableData11.value.push({
    ...defaultRowData11,
  });
};
const deleteRow2 = (row: any) => {
  const index = tableData2.value.indexOf(row);
  if (index != -1) {
    tableData2.value.splice(index, 1);
  }
};
const deleteRow3 = (row: any) => {
  const index = tableData3.value.indexOf(row);
  if (index != -1) {
    tableData3.value.splice(index, 1);
  }
};
// const deleteRow4 = (row: any) => {
//   const index = tableData4.value.indexOf(row);
//   if (index != -1) {
//     tableData4.value.splice(index, 1);
//   }
// };
const deleteRow5 = (row: any) => {
  const index = tableData5.value.indexOf(row);
  if (index != -1) {
    tableData5.value.splice(index, 1);
  }
};
const deleteRow6 = (row: any) => {
  const index = tableData6.value.indexOf(row);
  if (index != -1) {
    tableData6.value.splice(index, 1);
  }
};
const deleteRow7 = (row: any) => {
  const index = tableData7.value.indexOf(row);
  if (index != -1) {
    tableData7.value.splice(index, 1);
  }
};
const deleteRow8 = (row: any) => {
  const index = tableData8.value.indexOf(row);
  if (index != -1) {
    tableData8.value.splice(index, 1);
  }
};
const deleteRow9 = (row: any) => {
  const index = tableData9.value.indexOf(row);
  if (index != -1) {
    tableData9.value.splice(index, 1);
  }
};
const deleteRow10 = (row: any) => {
  const index = tableData10.value.indexOf(row);
  if (index != -1) {
    tableData10.value.splice(index, 1);
  }
};
const deleteRow11 = (row: any) => {
  const index = tableData11.value.indexOf(row);
  if (index != -1) {
    tableData11.value.splice(index, 1);
  }
};
// // 设置表头样式
const headerCellStyle = {
  // E9E9E7
  borderColor: "#B9C9C7",
  backgroundColor: "#F2F4FA", // 表头背景颜色
  fontWeight: "bold", // 表头文字粗细
  color: "#1F2129",
  textAlign: "center",
  // padding: "0 0 0 30px",
};

const rowState = (arg) => {
  return {
    height: "20px", // 设置合适的行高值
    fontSize: "12px", // 设置合适的字体大小值
    // color: "black",
  };
};
const RowClick = (row, selection) => {
  table.value.toggleRowSelection(row);
};
const handleRowClick = async (row, selection) => {
  //   await OFFdialogTableVisible();
  try {
    const res = await crud.fetchData(
      "/Gri/select/GrindingProcessStandard/MainId",
      "post",
      {
        id: row.id,
      }
    );

    dialogTableVisible.value = true;
    showInsertButton.value = false;
    formMainTable.value = { ...formMainTable.value, ...res[0] };
    //  formMainTable.value.model = res[0].
    formMainTable.value.uElementRange = res[0].uelementRange;
    formMainTable.value.bElementRange = res[0].belementRange;
    formMainTable.value.wElementRange = res[0].welementRange;
    formMainTable.value.hElementRange = res[0].helementRange;
    formMainTable.value.oElementRange = res[0].oelementRange;
    formMainTable.value.cElementRange = res[0].celementRange;
    formMainTable.value.pElementRange = res[0].pelementRange;
    formMainTable.value.sElementRange = res[0].selementRange;
    formMainTable.value.nElementRange = res[0].nelementRange;
    formMainTable.value.processProperty = res[0].processProperty.toString();
    formMainTable.value.procedures = res[0].procedures.toString();
    await handleReplacementMethodChange();
    //  row.isDisabled = false;

    //  for(let i =0;i<res.technicalStandardList.length;i++){

    //  }
    formMainTable.value.cycleMethod = row.cycleMethod;
    if (formMainTable.value.standardType == 1) {
      isDisabledleri.value = false;
      isReplacementMethod.value = false;
    }
    if (formMainTable.value.type == 0) {
      isMx.value = false;
    } else {
      isMx.value = true;
    }
    //技术标准
    tableData1.value = [];
    const technicalStandardListArray = Object.values(res[0].technicalStandardList);
    tableData1.value = [...tableData1.value, ...technicalStandardListArray];
    while (tableData1.value.length < 8) {
      tableData1.value.push({ ...defaultRowData1, project: "7" });
    }

    // 对行进行处理
    tableData1.value = tableData1.value.map((row) => {
      if (row.valueRangeType == "0") {
        row.isDisabled = true;
      }
      return row;
    });

    //磨削道次
    tableData2.value = [];
    const grindingPassListArray = Object.values(res[0].grindingPassList);
    tableData2.value = [...tableData2.value, ...grindingPassListArray];
    //更换类别
    tableData3.value = [];
    const replacementCategoryListArray = Object.values(res[0].replacementCategoryList);
    tableData3.value = [...tableData3.value, ...replacementCategoryListArray];
    const rowData3 = { ...defaultRowData3 };
    tableData3.value.push(rowData3);
    //磨削耗用人工
    tableData5.value = [];
    const grindingConsumptionLaborListArray = Object.values(
      res[0].grindingConsumptionLaborList
    );
    tableData5.value = [...tableData5.value, ...grindingConsumptionLaborListArray];
    const rowData5 = { ...defaultRowData5 };
    tableData5.value.push(rowData5);
    //磨削耗用辅助材料表
    tableData6.value = [];
    const grindingConsumptionAuxiliaryMaterialsListArray = Object.values(
      res[0].grindingConsumptionAuxiliaryMaterialsList
    );
    tableData6.value = [
      ...tableData6.value,
      ...grindingConsumptionAuxiliaryMaterialsListArray,
    ];
    const rowData6 = { ...defaultRowData6 };
    tableData6.value.push(rowData6);
    //磨削（自制）耗用费用项目
    tableData7.value = [];
    const grindingInhouseConsumptionExpenseItemListArray = Object.values(
      res[0].grindingInhouseConsumptionExpenseItemList
    );
    tableData7.value = [
      ...tableData7.value,
      ...grindingInhouseConsumptionExpenseItemListArray,
    ];

    //  tableData7.value.push(...defaultRowData7);
    const rowData7 = { ...defaultRowData7 };
    tableData7.value.push(rowData7);
    //磨削工步设置表
    tableData8.value = [];
    const grindingProcessStepSettingListArray = Object.values(
      res[0].grindingProcessStepSettingList
    );
    tableData8.value = [...tableData8.value, ...grindingProcessStepSettingListArray];
    const rowData8 = { ...defaultRowData8 };
    tableData8.value.push(rowData8);
    //磨削（委外）耗用费用项目
    tableData9.value = [];
    const grindingOutsourcedConsumptionExpenseItemListArray = Object.values(
      res[0].grindingOutsourcedConsumptionExpenseItemList
    );
    tableData9.value = [
      ...tableData9.value,
      ...grindingOutsourcedConsumptionExpenseItemListArray,
    ];
    const rowData9 = { ...defaultRowData9 };
    tableData8.value.push(rowData9);
    //专用磨削设备设定
    tableData10.value = [];
    const specializedGrindingEquipmentSetupListArray = Object.values(
      res[0].specializedGrindingEquipmentSetupList
    );
    tableData10.value = [
      ...tableData10.value,
      ...specializedGrindingEquipmentSetupListArray,
    ];
    const rowData10 = { ...defaultRowData10 };
    tableData10.value.push(rowData10);
    //专用班组specializedGrindingTeamMain
    formSubTable11.value = {
      ...formMainTable.value,
      ...res[0].specializedGrindingTeamMain,
    };
    tableData11.value = [];
    const specializedGrindingTeamSubListArray = Object.values(
      res[0].specializedGrindingTeamSubList
    );
    tableData11.value = [...tableData11.value, ...specializedGrindingTeamSubListArray];
    const rowData11 = { ...defaultRowData11 };
    tableData11.value.push(rowData11);
  } catch (error) {
    console.error("请求失败:", error);
  }
};
const cellStyle = ({ row, column, rowIndex, columnIndex }) => {
  if (selectedRows.value.find((selectedRow) => selectedRow.id === row.id)) {
    return {
      backgroundColor: "#DFF0DB !important",
      borderColor: "#B9C9C7",
      padding: "4px",
    };
  } else {
    // #E9E9E7
    // D9D9D7   C9C9C7 A9A9A7

    return { borderColor: "#B9C9C7", padding: "4px", margin: 0 };
  }
};
// 子表样式
const cellStyle1 = ({ row, column, rowIndex, columnIndex }) => {
  return { borderColor: "#B9C9C7", padding: "0px", margin: 0 };
};
const headerCellStyle1 = {
  borderColor: "#B9C9C7",
  backgroundColor: "#F2F4FA",
  fontWeight: "bold",
  color: "#1F2129",
  height: "40px",
  margin: 0,
  padding: 0,
};
// 弹窗设置
const sed = ref<any>(null);
const sea = ref<any>(null);
const seb = ref<any>(null);
const sec = ref<any>(null);
const see = ref<any>(null);
const sef = ref<any>(null);
const seg = ref<any>(null);
const seh = ref<any>(null);
const sei = ref<any>(null);
const sej = ref<any>(null);
const openEqipmentParts = async () => {
  sed.value.dialogTableVisible = true;
  isReplacementMethod.value = false;
  formMainTable.value.cycleMethod = "";
  openDial();
};
const openEqipmentParts1 = async () => {
  sea.value.dialogTableVisible = true;
  openDial1();
};
const openEqipmentParts2 = async () => {
  seb.value.dialogTableVisible = true;
  openDial2();
};

const isDisabprocessProperty = ref(false);
const openprocessProperty = async () => {
  isDisabprocessProperty.value = false;
  if (
    formMainTable.value.processProperty == "1" ||
    formMainTable.value.processProperty == "3"
  ) {
    tableData3.value.forEach((row) => {
      // console.log(row);
      row.processProperty = "0";
      isDisabprocessProperty.value = true;
    });
  }
  if (
    formMainTable.value.processProperty == "2" ||
    formMainTable.value.processProperty == "4"
  ) {
    tableData3.value.forEach((row) => {
      row.processProperty = "1";
      isDisabprocessProperty.value = true;
    });
  }
  if (formMainTable.value.processProperty == "5") {
    tableData3.value.forEach((row) => {
      row.processProperty = "2";
      isDisabprocessProperty.value = true;
    });
  }
};

const indexOpenEqipmentParts3 = ref(0);
const openEqipmentParts3 = async (index) => {
  indexOpenEqipmentParts3.value = index;
  sec.value.dialogTableVisible = true;
  openDial3();
};
const indexEmployeeJob = ref(0);
const openEqipmentParts4 = async (index) => {
  indexEmployeeJob.value = index;
  see.value.dialogTableVisible = true;
  openDial4();
};
const indexEqipmentParts5 = ref(0);
const openEqipmentParts5 = async (index) => {
  indexEqipmentParts5.value = index;
  sef.value.dialogTableVisible = true;
  openDial5();
};
const indexOpenEqipmentParts6 = ref(0);
const openEqipmentParts6 = async (index) => {
  indexOpenEqipmentParts6.value = index;
  seg.value.dialogTableVisible = true;
  openDial6();
};
const indexEqipmentParts7 = ref(0);
const openEqipmentParts7 = async (index) => {
  indexEqipmentParts7.value = index;
  seh.value.dialogTableVisible = true;
  openDial7();
};
const indexEqipmentParts8 = ref(0);
const openEqipmentParts8 = async (index) => {
  indexEqipmentParts8.value = index;
  sei.value.dialogTableVisible = true;
  openDial8();
};
const openEqipmentParts9 = async (index) => {
  sej.value.dialogTableVisible = true;
  openDial9();
};
const tableDemo = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  //   { type: "selection", width: "65", align: "center" },
  { prop: "structureName", label: "结构名称", width: "120", align: "center" },
  { prop: "name", label: "设备零件", width: "150", align: "center" },
  { prop: "model", label: "型号", width: "150", align: "center" },
  { prop: "consumableCategoryName", label: "耗材类别", width: "120", align: "center" },
]);
const tableDemo1 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  //   { type: "selection", width: "65", align: "center" },
  { prop: "ytbm", label: "编码", width: "120", align: "center" },
  { prop: "ytfl", label: "分类", width: "120", align: "center" },
  { prop: "ytmc", label: "用途", width: "150", align: "center" },
  { prop: "remark", label: "备注", width: "150", align: "center" },
]);
const tableDemo3 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  //   { type: "selection", width: "65", align: "center" },
  { prop: "jobName", label: "岗位名称", width: "120", align: "center" },
]);
const tableDemo4 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  //   { type: "selection", width: "65", align: "center" },
  //   { prop: "id", label: "Id", width: "120", align: "center" },
  { prop: "fnumber", label: "编码", width: "120", align: "center" },
  { prop: "bmmc", label: "k3名称", width: "150", align: "center" },
  { prop: "wlgg", label: "物料规格", width: "150", align: "center" },
  { prop: "jldw", label: "计量单位", width: "150", align: "center" },
]);
const tableDemo5 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  // { type: "selection", width: "65", align: "center" },
  //   { prop: "id", label: "id", width: "120", align: "center" },
  { prop: "code", label: "编码", width: "120", align: "center" },
  { prop: "name", label: "项目名称", width: "150", align: "center" },
  { prop: "description", label: "说明", width: "150", align: "center" },
]);
const tableDemo6 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  //   { type: "selection", width: "65", align: "center" },
  { prop: "jobName", label: "岗位名称", width: "120", align: "center" },
]);
const tableDemo8 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  //   { type: "selection", width: "65", align: "center" },
  { prop: "equipmentCode", label: "设备编码", width: "120", align: "center" },
  { prop: "equipmentName", label: "设备名称", width: "120", align: "center" },
  { prop: "description", label: "说明", width: "120", align: "center" },
]);
const tableDemo9 = ref([
  { type: "index", fixed: true, width: "60", align: "center" },
  //   { type: "selection", width: "65", align: "center" },
  //   { prop: "teamID", label: "ID", width: "120", align: "center" },
  { prop: "code", label: "班组编号", width: "120", align: "center" },
  { prop: "teamName", label: "班组名称", width: "150", align: "center" },
  { prop: "description", label: "说明", width: "150", align: "center" },
]);
const openDial = () => {
  sed.value.ifRowChoose = false;
  sed.value.ifdynamic1 = true;
  sed.value.ifdynamic2 = true;
  sed.value.dynamicPlaceholder1 = "零件名称";
  sed.value.dynamicPlaceholder2 = "结构名称";
  sed.value.ifdynamic3 = false;
  sed.value.tableColumns = tableDemo.value;
  sed.value.apiUrl = "/CoInformation/select/ComponentBasicInformation";
  sed.value.searchInput();
};
const openDial1 = () => {
  sea.value.ifRowChoose = false;
  sea.value.ifdynamic1 = true;
  sea.value.ifdynamic2 = true;
  sea.value.ifdynamic3 = true;
  sea.value.dynamicPlaceholder1 = "用途编码";
  sea.value.dynamicPlaceholder2 = "用途分类";
  sea.value.dynamicPlaceholder3 = "用途名称";
  sea.value.tableColumns = tableDemo1.value;
  sea.value.apiUrl = "/Material/Select/UseDefinition/Mc";
  sea.value.searchInput();
};
const openDial2 = () => {
  seb.value.ifRowChoose = false;
  seb.value.ifdynamic1 = true;
  seb.value.ifdynamic2 = true;
  seb.value.ifdynamic3 = true;
  seb.value.dynamicPlaceholder1 = "材质编码";
  seb.value.dynamicPlaceholder2 = "材质分类";
  seb.value.dynamicPlaceholder3 = "材质名称";
  seb.value.tableColumns = tableDemo1.value;
  seb.value.apiUrl = "/Mat/Select/UseDefinition/Mc";
  seb.value.searchInput();
};
const openDial3 = () => {
  sec.value.ifRowChoose = false;
  sec.value.ifdynamic1 = false;
  sec.value.ifdynamic2 = false;
  sec.value.ifdynamic3 = false;
  sec.value.tableColumns = tableDemo3.value;
  sec.value.apiUrl = "/Admin/select/ User/Job/";
  sec.value.searchInput();
};
const openDial4 = () => {
  see.value.ifdynamic1 = true;
  see.value.ifdynamic2 = true;
  see.value.dynamicPlaceholder1 = "物料编码";
  see.value.dynamicPlaceholder2 = "物料名称";
  see.value.ifdynamic3 = false;
  see.value.tableColumns = tableDemo4.value;
  see.value.apiUrl = "/get/K3bm/Mc";
  see.value.searchInput();
  //多选调整
  see.value.compareValue = "id";
  see.value.ifRowChoose = true;
};
const openDial5 = () => {
  sef.value.ifdynamic1 = false;
  sef.value.ifdynamic2 = false;
  sef.value.ifdynamic3 = false;
  sef.value.tableColumns = tableDemo5.value;
  sef.value.apiUrl = "/select/ExpenseItemInfoTable/Auto1";
  sef.value.searchInput();
  //多选调整
  sef.value.compareValue = "id";
  sef.value.ifRowChoose = true;
};
const openDial6 = () => {
  seg.value.ifRowChoose = false;
  seg.value.ifdynamic1 = false;
  seg.value.ifdynamic2 = false;
  seg.value.ifdynamic3 = false;
  seg.value.tableColumns = tableDemo3.value;
  seg.value.apiUrl = "/Admin/select/ User/Job/";
  seg.value.searchInput();
};
const openDial7 = () => {
  seh.value.ifdynamic1 = false;
  seh.value.ifdynamic2 = false;
  seh.value.ifdynamic3 = false;
  seh.value.tableColumns = tableDemo5.value;
  seh.value.apiUrl = "/select/ExpenseItemInfoTable/Auto1";
  seh.value.searchInput();
  //多选调整
  seh.value.compareValue = "id";
  seh.value.ifRowChoose = true;
};
const openDial8 = () => {
  sei.value.ifRowChoose = false;
  sei.value.ifdynamic1 = true;
  sei.value.ifdynamic2 = true;
  sei.value.dynamicPlaceholder1 = "设备编号";
  sei.value.dynamicPlaceholder2 = "设备名称";
  sei.value.ifdynamic3 = false;
  sei.value.tableColumns = tableDemo8.value;
  sei.value.apiUrl = "/Eq/select/EquipmentBasicInfo/Auto1";
  sei.value.searchInput();
};
const openDial9 = () => {
  sej.value.ifRowChoose = false;
  sej.value.ifdynamic1 = true;
  sej.value.ifdynamic2 = true;
  sej.value.dynamicPlaceholder1 = "班组名称";
  sej.value.dynamicPlaceholder2 = "班组名称";

  sej.value.ifdynamic3 = false;
  sej.value.tableColumns = tableDemo9.value;
  sej.value.apiUrl = "/Team/select/Team/Auto1/tc";
  sej.value.searchInput();
};
const handleRowData = async (row) => {
  console.log(row);
  //名称
  formMainTable.value.consumableCategoryName = row.consumableCategoryName;
  formMainTable.value.name = row.name;
  formMainTable.value.structureName = row.structureName;
  //id
  //设备零件id componentId
  formMainTable.value.equipmentParts = row.componentId;
  formMainTable.value.equipmentStructure = row.structureCode;
  formMainTable.value.consumableCategory = row.consumableCategory;
  //存型号ID
  formMainTable.value.modelName = row.model;
  formMainTable.value.model = row.id;
};
const handleRowData1 = async (row) => {
  formMainTable.value.productPurpose = row.id;
  formMainTable.value.productPurposeName = row.ytmc;
};
const handleRowData2 = async (row) => {
  formMainTable.value.material = row.id;
  formMainTable.value.materialName = row.ytmc;
};
const handleRowData3 = async (row) => {
  const index = indexOpenEqipmentParts3.value;
  const existingIndex = tableData5.value.findIndex((item) => item.position === row.jobId);

  if (existingIndex !== -1 && existingIndex !== index) {
    notifications.showMessage(
      `已经存在 岗位 为 ${row.jobName} 的记录，不能重复添加`,
      "error"
    );
    return;
  }

  tableData5.value[index].position = row.jobId;
  tableData5.value[index].positionName = row.jobName;
  //   tableData5.value[indexOpenEqipmentParts3.value].position = row.jobId;
  //   tableData5.value[indexOpenEqipmentParts3.value].positionName = row.jobName;
};
// indexEmployeeJob
const handleRowDatas4 = async (row) => {
  const index = indexEmployeeJob.value;
  const rowLength = row.length;
  for (let i = 0; i < rowLength; i++) {
    const targetIndex = index + i;
    if (targetIndex >= tableData6.value.length) {
      break;
    }
    const fnumber = row[i].fnumber;
    const isDuplicate = tableData6.value.some((item) => item.materialCode === fnumber);

    if (isDuplicate) {
      notifications.showMessage(
        `已经存在 物料编码 为 ${fnumber} 的记录，不能重复添加，序号为 ${i + 1}`,
        "error"
      );
      continue;
    }
    tableData6.value[targetIndex].materialCode = fnumber;
    tableData6.value[targetIndex].materialName = row[i].bmmc;
    tableData6.value[targetIndex].id = row[i].id;
    tableData6.value[targetIndex].materialSpecification = row[i].wlgg;
    tableData6.value[targetIndex].measurementUnit = row[i].jldw;
  }
};
const handleRowDatas5 = async (row) => {
  const index = indexEqipmentParts5.value;
  const rowLength = row.length;
  for (let i = 0; i < rowLength; i++) {
    const targetIndex = index + i;
    if (targetIndex >= tableData7.value.length) {
      break;
    }
    const code = row[i].code;
    const isDuplicate = tableData7.value.some((item) => item.expenseCode === code);

    if (isDuplicate) {
      notifications.showMessage(
        `已经存在 编码 为 ${code} 的记录，不能重复添加，序号为 ${i + 1}`,
        "error"
      );
      continue;
    }
    tableData7.value[targetIndex].expenseCode = row[i].code;
    tableData7.value[targetIndex].expenseName = row[i].name;

    //  tableData6.value[targetIndex].materialCode = fnumber;
    //  tableData6.value[targetIndex].materialName = row[i].bmmc;
    //  tableData6.value[targetIndex].id = row[i].id;
    //  tableData6.value[targetIndex].materialSpecification = row[i].wlgg;
    //  tableData6.value[targetIndex].measurementUnit = row[i].jldw;
  }
};
const handleRowData6 = async (row) => {
  tableData8.value[indexOpenEqipmentParts6.value].position = row.jobId;
  tableData8.value[indexOpenEqipmentParts6.value].positionName = row.jobName;
};
const handleRowDatas7 = async (row) => {
  const index = indexEqipmentParts7.value;
  const rowLength = row.length;
  for (let i = 0; i < rowLength; i++) {
    const targetIndex = index + i;
    if (targetIndex >= tableData9.value.length) {
      break;
    }
    const code = row[i].code;
    const isDuplicate = tableData9.value.some((item) => item.expenseCode === code);

    if (isDuplicate) {
      notifications.showMessage(
        `已经存在 编码 为 ${code} 的记录，不能重复添加，序号为 ${i + 1}`,
        "error"
      );
      continue;
    }
    tableData9.value[targetIndex].expenseCode = row[i].code;
    tableData9.value[targetIndex].expenseName = row[i].name;

    //  tableData6.value[targetIndex].materialCode = fnumber;
    //  tableData6.value[targetIndex].materialName = row[i].bmmc;
    //  tableData6.value[targetIndex].id = row[i].id;
    //  tableData6.value[targetIndex].materialSpecification = row[i].wlgg;
    //  tableData6.value[targetIndex].measurementUnit = row[i].jldw;
  }
};
const handleRowData8 = async (row) => {
  const index = indexEqipmentParts8.value;
  const existingIndex = tableData10.value.findIndex(
    (item) => item.equipmentCode === row.structureCode
  );

  if (existingIndex !== -1 && existingIndex !== index) {
    notifications.showMessage(
      `已经存在设备编码为 ${row.structureCode} 的记录，不能重复添加`,
      "error"
    );
    return;
  }

  tableData10.value[index].equipmentCode = row.equipmentCode;
  tableData10.value[index].equipmentName = row.equipmentName;
  //   tableData10.value[indexEqipmentParts8.value].equipmentCode = row.structureCode;
  //   tableData10.value[indexEqipmentParts8.value].equipmentName = row.structureName;
};
const handleRowData9 = async (row) => {
  tableData11.value = [];
  try {
    const idDmt = ref({
      TeamId: row.teamID,
    });
    const res = await crud.fetchData(
      "/Team/select/TeamPersonnel/TeamId",
      "post",
      idDmt.value
    );
    if (res.length > 0) {
      for (let a = 0; a < res.length; a++) {
        const rowData11 = { ...defaultRowData11 };
        tableData11.value.push(rowData11);
        tableData11.value[a].employeeID = res[a].username;
        tableData11.value[a].employeeName = res[a].name;
      }
    }
    formSubTable11.value.teamCode = row.code;
    formSubTable11.value.teamName = row.teamName;
  } catch (error) {
    console.error("请求失败:", error);
  }
};
const isDisabledleri = ref(true);
// 数据验证
const clickOrganizationSelect = () => {
  //   通用标准
  if (formMainTable.value.standardType == "0") {
    isDisabledleri.value = true;

    // 标准类型，默认值为 "0"
    //  formMainTable.value.standardType = "0";

    // 状态，默认为空字符串
    //  formMainTable.value.state = "";

    // 设备零件，默认为空字符串
    //  formMainTable.value.equipmentParts = "";

    // 零件的名称，默认为空字符串
    //  formMainTable.value.name = "";

    // 设备结构，默认为空字符串
    //  formMainTable.value.equipmentStructure = "";

    // 设备名称，默认为空字符串
    //  formMainTable.value.structureName = "";

    // 耗材类别，默认为空字符串
    //  formMainTable.value.consumableCategory = "";

    // 耗材类别名称，默认为空字符串
    //  formMainTable.value.consumableCategoryName = "";

    // 型号，默认为空字符串
    //  formMainTable.value.model = "";

    // 产品用途ID，默认为空字符串
    //  formMainTable.value.productPurpose = "";

    // 产品用途名称，默认为空字符串
    //  formMainTable.value.productPurposeName = "";

    // 材质，默认为空字符串
    //  formMainTable.value.material = "";

    // 材质名称，默认为空字符串
    //  formMainTable.value.materialName = "";
    //工序
    formMainTable.value.procedures = "0";
    // 工序属性，默认值为 "0"
    formMainTable.value.processProperty = "0";

    // 磨削道次数，默认值为 0
    //  formMainTable.value.passToolNumber = 0;

    // 成品厚度，默认为空字符串
    formMainTable.value.finishedThickness = "";

    // 成品宽度，默认值为 0.0
    formMainTable.value.finishedWidth = 0.0;

    // 硬度范围，默认为空字符串
    formMainTable.value.hardnessRange = "";

    // 延伸率范围，默认为空字符串
    formMainTable.value.elongationRange = "";

    // 成品粗糙度范围，默认为空字符串
    formMainTable.value.surfaceRoughnessRange = "";

    // 抗拉范围，默认为空字符串
    formMainTable.value.tensileRange = "";

    // 硬化系数范围，默认为空字符串
    formMainTable.value.hardenabilityRange = "";

    // Ti元素范围，默认为空字符串
    formMainTable.value.tiElementRange = "";

    // Ta元素范围，默认为空字符串
    formMainTable.value.taElementRange = "";

    // Nb元素范围，默认为空字符串
    formMainTable.value.nbElementRange = "";

    // Al元素范围，默认为空字符串
    formMainTable.value.alElementRange = "";

    // Zr元素范围，默认为空字符串
    formMainTable.value.zrElementRange = "";

    // U元素范围，默认为空字符串
    formMainTable.value.uElementRange = "";

    // B元素范围，默认为空字符串
    formMainTable.value.bElementRange = "";

    // Fe元素范围，默认为空字符串
    formMainTable.value.feElementRange = "";

    // Co元素范围，默认为空字符串
    formMainTable.value.coElementRange = "";

    // W元素范围，默认为空字符串
    formMainTable.value.wElementRange = "";

    // H元素范围，默认为空字符串
    formMainTable.value.hElementRange = "";

    // O元素范围，默认为空字符串
    formMainTable.value.oElementRange = "";

    // C元素范围，默认为空字符串
    formMainTable.value.cElementRange = "";

    // Si元素范围，默认为空字符串
    formMainTable.value.siElementRange = "";

    // Mn元素范围，默认为空字符串
    formMainTable.value.mnElementRange = "";

    // P元素范围，默认为空字符串
    formMainTable.value.pElementRange = "";

    // S元素范围，默认为空字符串
    formMainTable.value.sElementRange = "";

    // Cr元素范围，默认为空字符串
    formMainTable.value.crElementRange = "";

    // Ni元素范围，默认为空字符串
    formMainTable.value.niElementRange = "";

    // Mo元素范围，默认为空字符串
    formMainTable.value.moElementRange = "";

    // Cu元素范围，默认为空字符串
    formMainTable.value.cuElementRange = "";

    // N元素范围，默认为空字符串
    formMainTable.value.nElementRange = "";

    // 周期方式，默认值为 "0"
    //  formMainTable.value.cycleMethod = "0";

    // 更换方式，默认值为 "0"
    //  formMainTable.value.replacementMethod = "0";

    // 工时单位，默认值为 "0"
    //  formMainTable.value.manHourUnit = "0";

    // 工时时长，默认为空字符串
    //  formMainTable.value.manHourDuration = "";

    // 类型，默认值为 "0"
    //  formMainTable.value.type = "0";

    return;
  }
  isDisabledleri.value = false;
};
const clickOrganizationSelect1 = () => {
  if (formMainTable.value.type == "0") {
    isMx.value = false;
  } else {
    isMx.value = true;
  }

  //   if (formMainTable.value.type == "0") {
  //     isMx.value = false;
  //     links.value = [
  //       { id: "part1", href: "#part1", title: "技术标准" },
  //       { id: "part2", href: "#part2", title: "磨削道次" },
  //       { id: "part3", href: "#part3", title: "更换类别" },
  //       { id: "part4", href: "#part4", title: "磨削标准工时" },
  //       { id: "part5", href: "#part5", title: "磨削耗用人工" },
  //       { id: "part6", href: "#part6", title: "磨削耗用辅助材料" },
  //       { id: "part7", href: "#part7", title: "磨削（自制）耗用费用项目" },
  //       { id: "part8", href: "#part8", title: "磨削工步设置" },
  //       { id: "part9", href: "#part9", title: "磨削（委外）耗用费用项目" },
  //       { id: "part10", href: "#part10", title: "专用磨削设备设定" },
  //       { id: "part11", href: "#part11", title: "专用磨削班组" },
  //     ];
  //   } else {
  //     isMx.value = true;
  //     links.value = [
  //       { id: "part4", href: "#part4", title: "标准工时" },
  //       { id: "part5", href: "#part5", title: "人工" },
  //       { id: "part6", href: "#part6", title: "消耗辅助材料" },
  //       { id: "part7", href: "#part7", title: "消耗（自制）费用项目" },
  //       { id: "part8", href: "#part8", title: "步骤设置" },
  //       { id: "part9", href: "#part9", title: "消耗（委外）费用项目" },
  //     ];
  //   }
  tableData1.value = [];
  tableData2.value = [];
  tableData3.value = [];
  tableData5.value = [];
  tableData6.value = [];
  tableData7.value = [];
  tableData8.value = [];
  tableData9.value = [];
  tableData10.value = [];
  tableData11.value = [];
  for (let i = 0; i < 7; i++) {
    const rowData1 = { ...defaultRowData1 };
    rowData1.project = String(i);
    tableData1.value.push(rowData1);
  }
  for (let i = 0; i < 5; i++) {
    const rowData2 = { ...defaultRowData2 };
    const rowData3 = { ...defaultRowData3 };
    const rowData5 = { ...defaultRowData5 };
    const rowData6 = { ...defaultRowData6 };
    const rowData7 = { ...defaultRowData7 };
    const rowData8 = { ...defaultRowData8 };
    const rowData9 = { ...defaultRowData9 };
    const rowData10 = { ...defaultRowData10 };
    const rowData11 = { ...defaultRowData11 };

    tableData2.value.push(rowData2);
    tableData3.value.push(rowData3);
    tableData5.value.push(rowData5);
    tableData6.value.push(rowData6);
    tableData7.value.push(rowData7);
    tableData8.value.push(rowData8);
    tableData9.value.push(rowData9);
    tableData10.value.push(rowData10);
    tableData11.value.push(rowData11);
  }
};
// 规则校验
const handleInput = (prop) => {
  if (prop === "passToolNumber") {
    if (formMainTable.value[prop] === "") {
      formMainTable.value[prop] = 0;
    } else {
      formMainTable.value[prop] = formMainTable.value[prop].replace(/\D/g, "");
    }
    return;
  }
  //   const valString = formMainTable.value[prop].replace(/,/g, "");
  //   const val = parseFloat(valString);
  const val = parseFloat(formMainTable.value[prop]);
  if (!isNaN(val) && isFinite(val)) {
    //  const roundedVal = val.toFixed(4);
    const roundedVal = val.toString().match(/^-?\d+(\.\d{0,4})?/)[0];
    //  const formattedVal = formatNumberToCurrency(roundedVal);
    formMainTable.value[prop] = roundedVal;
  } else {
    formMainTable.value[prop] = 0;
  }
};

const handleInput1 = (row, index) => {
  if (row.valueRangeType == "0" || row.valueRangeType == "1") {
    //  const valString = row.standard.replace(/,/g, "");
    //  const val = parseFloat(valString);
    const val = parseFloat(row.standard);
    if (!isNaN(val) && isFinite(val)) {
      // const roundedVal = val.toFixed(4);
      const roundedVal = val.toString().match(/^-?\d+(\.\d{0,4})?/)[0];

      // const formattedVal = formatNumberToCurrency(roundedVal);
      row.standard = roundedVal;
    } else {
      row.standard = "";
    }
  }
};
const handleInput0 = (row, index, prop) => {
  if (row.valueRangeType == "1" || row.valueRangeType == "3") {
    const val = parseFloat(row[prop]);
    if (!isNaN(val) && isFinite(val)) {
      // const roundedVal = val.toFixed(4);
      const roundedVal = val.toString().match(/^-?\d+(\.\d{0,4})?/)[0];

      row[prop] = roundedVal;
    } else {
      row[prop] = 0;
    }
  }
};
const handleInput2 = (row, index, prop) => {
  const val = parseFloat(row[prop]);
  if (!isNaN(val) && isFinite(val)) {
    //  const roundedVal = val.toFixed(4);
    const roundedVal = val.toString().match(/^-?\d+(\.\d{0,4})?/)[0];

    if (
      prop == "taperHeight" ||
      (prop == "taperLengthStandard" &&
        row.taperHeight != 0 &&
        row.taperLengthStandard !== 0)
    ) {
      const taperLengthStandard = parseFloat(row.taperLengthStandard);
      const taperHeight = parseFloat(row.taperHeight);
      if (taperLengthStandard != 0) {
        row.taperHeightRatio = (taperHeight / taperLengthStandard).toFixed(4);
      } else {
        row.taperHeightRatio = 0;
      }
    }
    row[prop] = roundedVal;
    return;
  }
  row[prop] = 0;
  if (prop == "taperHeight" || prop == "taperLengthStandard") {
    row.taperHeightRatio = "";
  }
};

const handleInput3 = (row, index, prop) => {
  if (prop == "cycleLength") {
    if (
      formMainTable.value.replacementMethod == 0 ||
      formMainTable.value.replacementMethod == 2
    ) {
      const val = parseFloat(row[prop]);
      if (!isNaN(val) && isFinite(val)) {
        //   const roundedVal = val.toFixed(4);
        const roundedVal = val.toString().match(/^-?\d+(\.\d{0,4})?/)[0];
        row[prop] = roundedVal;
      } else {
        row[prop] = 0;
      }
    }
    if (formMainTable.value.replacementMethod == 1) {
      if (row[prop] == "") {
        row[prop] = 0;
      } else {
        row[prop] = row[prop].replace(/\D/g, "");
      }
    }
  } else {
    const val = parseFloat(row[prop]);
    if (!isNaN(val) && isFinite(val)) {
      // const roundedVal = val.toFixed(4);
      const roundedVal = val.toString().match(/^-?\d+(\.\d{0,4})?/)[0];
      row[prop] = roundedVal;
    } else {
      row[prop] = 0;
    }
  }

  if (
    row.cycleUnitOutput != "" &&
    row.cycleLength != "" &&
    row.cycleUnitOutput != 0 &&
    row.cycleLength != 0
  ) {
    const unitOutput = parseFloat(row.cycleUnitOutput);
    const cycleLength = parseFloat(row.cycleLength);
    const cycleOutput = unitOutput * cycleLength;
    //  row.cycleOutput = cycleOutput.toFixed(4);
    row.cycleOutput = cycleOutput.toString().match(/^-?\d+(\.\d{0,4})?/)[0];
  }
};

const handleInput5 = (row, prop) => {
  const index = tableData5.value.indexOf(row);
  let cellValue = tableData5.value[index][prop];
  if (typeof cellValue === "string") {
    cellValue = cellValue.replace(/,/g, "");
  }
  const val = parseFloat(cellValue);
  //   const valString = tableData5.value[index][prop].replace(/,/g, "");
  //   const val = parseFloat(valString);
  if (!isNaN(val) && isFinite(val)) {
    const roundedVal = val.toFixed(0);
    const formattedVal = formatNumberToCurrency(roundedVal);
    tableData5.value[index][prop] = formattedVal;
  } else {
    tableData5.value[index][prop] = 0;
  }
};
// const handleInput3 = (row, index, prop) => {
//   if (prop == "cycleLength") {
//     console.log(formMainTable.value.replacementMethod);
//     if (
//       formMainTable.value.replacementMethod == 0 ||
//       formMainTable.value.replacementMethod == 2
//     ) {
//       const val = parseFloat(row[prop]);
//       if (!isNaN(val) && isFinite(val)) {
//         const roundedVal = val.toFixed(2);
//         row[prop] = roundedVal;
//         return;
//       }
//       row[prop] = 0;
//     }
//     if (formMainTable.value.replacementMethod == 1) {
//       if (row[prop] == "") {
//         row[prop] == 0;
//         return;
//       }
//       row[prop] = row[prop].replace(/\D/g, "");
//       return;
//     }
//     return;
//   }
//   const val = parseFloat(row[prop]);
//   if (!isNaN(val) && isFinite(val)) {
//     const roundedVal = val.toFixed(2);
//     row[prop] = roundedVal;
//     return;
//   }
//   row[prop] = 0;
// };

const handleInput6 = (row, index, prop) => {
  if (row[prop] === "") {
    row[prop] = 0;
  } else {
    row[prop] = row[prop].replace(/\D/g, "");
  }
};
const handleInput7 = (row, index, prop) => {
  const val = parseFloat(row[prop]);
  if (!isNaN(val) && isFinite(val)) {
    //  const roundedVal = val.toFixed(4);
    const roundedVal = val.toString().match(/^-?\d+(\.\d{0,4})?/)[0];

    //  const formattedVal = formatNumberToCurrency(roundedVal);
    row[prop] = roundedVal;
  } else {
    row[prop] = 0;
  }
};

const handleValueRangeChange = (row, index) => {
  row.isDisabled = false;
  row.isDisabled0 = false;
  if (row.valueRangeType == "0") {
    row.isDisabled = true;
    row.standard = "";
    row.toleranceUpperLimit = "";
    row.toleranceLowerLimit = "";
    return;
  }
  if (row.valueRangeType == "3") {
    row.isDisabled0 = true;
    row.standard = "";
    return;
  }
};
// 磨削道次：
watch(
  () => formMainTable.value.passToolNumber,
  (newValue, oldValue) => {
    tableData2.value = [];
    for (let i = 0; i < formMainTable.value.passToolNumber; i++) {
      const rowData2 = { ...defaultRowData2 };
      tableData2.value.push(rowData2);
    }
  },
  { deep: true }
);
//更换类别
const isReplacementMethod = ref(true);
const isTypeDisabled = ref(true);
const typeOptions = ref([]);
const columnLabel = ref("序号");
const handleReplacementMethodChange = () => {
  isTypeDisabled.value = false;
  formMainTable.value.cycleMethod = "";
  typeOptions.value = [];
  tableData3.value = [];
  for (let i = 0; i < 5; i++) {
    const rowData3 = { ...defaultRowData3 };
    tableData3.value.push(rowData3);
  }
  updateTypeOptions();
  if (formMainTable.value.consumableCategory == 0) {
    columnLabel.value = "道次";
    return;
  }
  if (formMainTable.value.consumableCategory == 1) {
    columnLabel.value = "刀次";
    return;
  }
  columnLabel.value = "序号";
};

const updateTypeOptions = () => {
  const replacementMethod = formMainTable.value.replacementMethod;
  // 根据不同的更换方式设置不同的类型选项
  if (replacementMethod === "0") {
    typeOptions.value = [
      { label: "天数", value: "0" },
      { label: "小时", value: "1" },
      { label: "分钟", value: "2" },
    ];
    return;
  }
  if (replacementMethod === "1") {
    if (formMainTable.value.consumableCategory == 0) {
      typeOptions.value = [{ label: "道次", value: "3" }];
      return;
    }
    if (formMainTable.value.consumableCategory == 1) {
      typeOptions.value = [{ label: "刀次", value: "4" }];
      return;
    }
    typeOptions.value = [{ label: "次", value: "5" }];
    return;
  }
  if (replacementMethod === "2") {
    typeOptions.value = [{ label: "产量", value: "6" }];
    return;
  }

  typeOptions.value = [];
};
// 获取当前时间
const getCurrentFormattedDateTime = () => {
  const currentDateTime = new Date();
  // 格式化当前时间
  const formattedDateTime = currentDateTime.toLocaleString("zh-CN", {
    year: "numeric",
    month: "2-digit",
    day: "2-digit",
    hour: "2-digit",
    minute: "2-digit",
    second: "2-digit",
  });
  // const formattedDateTime = format(currentDateTime, "YYYY-MM-dd HH:mm:ss");

  return formattedDateTime;
};
// 获取年月日
const getCurrentFormattedDate = () => {
  const currentDateTime = new Date();

  // 格式化当前时间，只获取年月日
  const formattedDate = currentDateTime.toLocaleString("zh-CN", {
    year: "numeric",
    month: "2-digit",
    day: "2-digit",
  });

  return formattedDate;
};
//保存
const requestFormTable = computed(() => {
  const tableDate3Lsit = tableData3.value.filter(
    (item) => item.cycleLength != "" || item.cycleLength != 0
  );
  const tableDate5Lsit = tableData5.value.filter((item) => item.position != "");
  const tableDate6Lsit = tableData6.value.filter((item) => item.materialCode != "");
  const tableDate7Lsit = tableData7.value.filter((item) => item.expenseCode != "");
  const tableDate8Lsit = tableData8.value.filter((item) => item.position != "");
  const tableDate9Lsit = tableData9.value.filter((item) => item.expenseCode != "");
  const tableDate10Lsit = tableData10.value.filter((item) => item.equipmentCode != "");
  const tableDate11Lsit = tableData11.value.filter((item) => item.employeeID != "");
  const creationTime: creationTime = getCurrentFormattedDateTime();
  const userName = Cookies.get("userName");
  return {
    creationTime: creationTime,
    userName: userName,
    formMainTable: formMainTable.value,
    formSubTable11: formSubTable11.value,
    tableDate1Lsit: tableData1.value,
    tableDate2Lsit: tableData2.value,
    tableDate3Lsit: tableDate3Lsit,
    tableDate5Lsit: tableDate5Lsit,
    tableDate6Lsit: tableDate6Lsit,
    tableDate7Lsit: tableDate7Lsit,
    tableDate8Lsit: tableDate8Lsit,
    tableDate9Lsit: tableDate9Lsit,
    tableDate10Lsit: tableDate10Lsit,
    tableDate11Lsit: tableDate11Lsit,
    id: formMainTable.value.id,
  };
});
// 磨削必填
const isTrue = ref(true);

const isRole = () => {
  isTrue.value = true;
  if (!formMainTable.value.processName) {
    notifications.showMessage("请填写工艺名称", "error");
    return;
  }
  if (!formMainTable.value.equipmentParts) {
    notifications.showMessage("请选择设备零件", "error");
    return;
  }
  //   if (!formMainTable.value.productPurpose) {
  //     notifications.showMessage("请选择用途", "error");
  //     return;
  //   }
  //   if (!formMainTable.value.material) {
  //     notifications.showMessage("请选择材质", "error");
  //     return;
  //   }
  //技术标准
  for (let i = 0; i < requestFormTable.value.tableDate1Lsit.length; i++) {
    if (requestFormTable.value.tableDate1Lsit[i].valueRangeType == 0) {
      if (
        //   requestFormTable.value.tableDate1Lsit[i].standard == 0 ||
        requestFormTable.value.tableDate1Lsit[i].standard == ""
      ) {
        notifications.showMessage(
          "请在技术标准表第" + [i + 1] + "行，填写标准数量",
          "error"
        );
        return;
      }
    }
    if (requestFormTable.value.tableDate1Lsit[i].valueRangeType == 1) {
      if (
        //   requestFormTable.value.tableDate1Lsit[i].standard == 0 ||
        requestFormTable.value.tableDate1Lsit[i].standard == ""
      ) {
        notifications.showMessage(
          "请在技术标准表第" + [i + 1] + "行，填写标准数量",
          "error"
        );
        return;
      }
      if (
        //   requestFormTable.value.tableDate1Lsit[i].toleranceLowerLimit == 0 ||
        requestFormTable.value.tableDate1Lsit[i].toleranceLowerLimit == ""
      ) {
        notifications.showMessage(
          "请在技术标准表第" + [i + 1] + "行，填写公差下限",
          "error"
        );
        return;
      }
      if (
        //   requestFormTable.value.tableDate1Lsit[i].toleranceUpperLimit == 0 ||
        requestFormTable.value.tableDate1Lsit[i].toleranceUpperLimit == ""
      ) {
        notifications.showMessage(
          "请在技术标准表第" + [i + 1] + "行，填写公差上限",
          "error"
        );
        return;
      }
    }
  }
  // 磨削道次
  for (let i = 0; i < requestFormTable.value.tableDate2Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate2Lsit[i].grindingQuantityStandard == 0 ||
      requestFormTable.value.tableDate2Lsit[i].grindingQuantityStandard == ""
    ) {
      notifications.showMessage(
        "请在磨削道次表第" + [i + 1] + "行，填写磨削标准",
        "error"
      );
      return;
    }
    if (
      // requestFormTable.value.tableDate2Lsit[i].grindingQuantityToleranceUpperLimit == 0 ||
      requestFormTable.value.tableDate2Lsit[i].grindingQuantityToleranceUpperLimit == ""
    ) {
      notifications.showMessage(
        "请在磨削道次表第" + [i + 1] + "行，填写磨削公差上限",
        "error"
      );
      return;
    }
    if (
      // requestFormTable.value.tableDate2Lsit[i].grindingQuantityToleranceLowerLimit == 0 ||
      requestFormTable.value.tableDate2Lsit[i].grindingQuantityToleranceLowerLimit == ""
    ) {
      notifications.showMessage(
        "请在磨削道次表第" + [i + 1] + "行，填写磨削公差下限",
        "error"
      );
      return;
    }
    if (
      // requestFormTable.value.tableDate2Lsit[i].roughnessStandard == 0 ||
      requestFormTable.value.tableDate2Lsit[i].roughnessStandard == ""
    ) {
      notifications.showMessage(
        "请在磨削道次表第" + [i + 1] + "行，填写粗糙度标准",
        "error"
      );
      return;
    }
    if (
      // requestFormTable.value.tableDate2Lsit[i].roughnessToleranceUpperLimit == 0 ||
      requestFormTable.value.tableDate2Lsit[i].roughnessToleranceUpperLimit == ""
    ) {
      notifications.showMessage(
        "请在磨削道次表第" + [i + 1] + "行，填写粗糙度上限",
        "error"
      );
      return;
    }
    if (
      // requestFormTable.value.tableDate2Lsit[i].roughnessToleranceLowerLimit == 0 ||
      requestFormTable.value.tableDate2Lsit[i].roughnessToleranceLowerLimit == ""
    ) {
      notifications.showMessage(
        "请在磨削道次表第" + [i + 1] + "行，填写粗糙度下限",
        "error"
      );
      return;
    }
    if (
      // requestFormTable.value.tableDate2Lsit[i].lateralShiftUpperLimit == 0 ||
      requestFormTable.value.tableDate2Lsit[i].lateralShiftUpperLimit == ""
    ) {
      notifications.showMessage(
        "请在磨削道次表第" + [i + 1] + "行，填写横移量上限",
        "error"
      );
      return;
    }
    if (
      // requestFormTable.value.tableDate2Lsit[i].lateralShiftLowerLimit == 0 ||
      requestFormTable.value.tableDate2Lsit[i].lateralShiftLowerLimit == ""
    ) {
      notifications.showMessage(
        "请在磨削道次表第" + [i + 1] + "行，填写横移量下限",
        "error"
      );
      return;
    }
  }
  //更换类别
  if (formMainTable.value.cycleMethod == "") {
    notifications.showMessage("请在更换类别表，填写周期方式", "error");
    return;
  }
  for (let i = 0; i < requestFormTable.value.tableDate3Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate3Lsit[i].cycleLength == 0 ||
      requestFormTable.value.tableDate3Lsit[i].cycleLength == ""
    ) {
      notifications.showMessage("请在更换类别表填写周期长度", "error");
      return;
    }

    if (
      // requestFormTable.value.tableDate3Lsit[i].cycleUnitOutput == 0 ||
      requestFormTable.value.tableDate3Lsit[i].cycleUnitOutput == ""
    ) {
      notifications.showMessage(
        "请在更换类别表第" + [i + 1] + "行，填写周期单位产量",
        "error"
      );
      return;
    }
  }
  //磨削标准工时
  if (formMainTable.value.manHourDuration == "") {
    notifications.showMessage("请在磨削标准工时表 ，填写工时时长", "error");
    return;
  }
  //磨削耗用人工
  for (let i = 0; i < requestFormTable.value.tableDate5Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate5Lsit[i].personnelNumber == 0 ||
      requestFormTable.value.tableDate5Lsit[i].personnelNumber == ""
    ) {
      notifications.showMessage(
        "请在磨削耗用人工表第" + [i + 1] + "行，填写人数",
        "error"
      );
      return;
    }
  }
  //磨削耗用辅助材料
  for (let i = 0; i < requestFormTable.value.tableDate6Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate6Lsit[i].quantity == 0 ||
      requestFormTable.value.tableDate6Lsit[i].quantity == ""
    ) {
      notifications.showMessage(
        "请在磨削耗用辅助材料表第" + [i + 1] + "行，填写数量",
        "error"
      );
      return;
    }
  }
  //磨削（自制）耗用费用项目
  for (let i = 0; i < requestFormTable.value.tableDate7Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate7Lsit[i].amount == 0 ||
      requestFormTable.value.tableDate7Lsit[i].amount == ""
    ) {
      notifications.showMessage(
        "请在磨削（自制）耗用费用项目表第" + [i + 1] + "行，填写金额",
        "error"
      );
      return;
    }
  }
  //磨削工步设置
  for (let i = 0; i < requestFormTable.value.tableDate8Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate8Lsit[i].stepName == 0 ||
      requestFormTable.value.tableDate8Lsit[i].stepName == ""
    ) {
      notifications.showMessage(
        "请在磨削（自制）耗用费用项目表第" + [i + 1] + "行，填写工步",
        "error"
      );
      return;
    }
    if (
      // requestFormTable.value.tableDate8Lsit[i].stepManHour == 0 ||
      requestFormTable.value.tableDate8Lsit[i].stepManHour == ""
    ) {
      notifications.showMessage(
        "请在磨削（自制）耗用费用项目表第" + [i + 1] + "行，工步工时",
        "error"
      );
      return;
    }
    if (
      // requestFormTable.value.tableDate8Lsit[i].personnelNumber == 0 ||
      requestFormTable.value.tableDate8Lsit[i].personnelNumber == ""
    ) {
      notifications.showMessage(
        "请在磨削（自制）耗用费用项目表第" + [i + 1] + "行，人数",
        "error"
      );
      return;
    }
  }
  //磨削（委外）耗用费用项目
  for (let i = 0; i < requestFormTable.value.tableDate9Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate9Lsit[i].amount == 0 ||
      requestFormTable.value.tableDate9Lsit[i].amount == ""
    ) {
      notifications.showMessage(
        "请在磨削（委外）耗用费用项目表第" + [i + 1] + "行，填写金额",
        "error"
      );
      return;
    }
  }
  //专用磨削班组
  if (formSubTable11.value.teamCode == "") {
    notifications.showMessage("请在专用磨削班组表第，填写班组编码", "error");
    return;
  }
  if (formSubTable11.value.teamName == "") {
    notifications.showMessage("请在专用磨削班组表第，填写班组名称", "error");
    return;
  }
  isTrue.value = false;
};
//安装必填
const isRole1 = () => {
  isTrue.value = true;
  if (!formMainTable.value.processName) {
    notifications.showMessage("请填写工艺名称", "error");
    return;
  }
  if (!formMainTable.value.equipmentParts) {
    notifications.showMessage("请选择设备零件", "error");
    return;
  }
  //   if (!formMainTable.value.productPurpose) {
  //     notifications.showMessage("请选择用途", "error");
  //     return;
  //   }
  //   if (!formMainTable.value.material) {
  //     notifications.showMessage("请选择材质", "error");
  //     return;
  //   }

  //标准工时
  if (formMainTable.value.manHourDuration == "") {
    notifications.showMessage("请在标准工时表 ，填写工时时长", "error");
  }
  //人工
  for (let i = 0; i < requestFormTable.value.tableDate5Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate5Lsit[i].personnelNumber == 0 ||
      requestFormTable.value.tableDate5Lsit[i].personnelNumber == ""
    ) {
      notifications.showMessage("请在人工表第" + [i + 1] + "行，填写人数", "error");
      return;
    }
  }
  //消耗辅助材料
  for (let i = 0; i < requestFormTable.value.tableDate6Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate6Lsit[i].quantity == 0 ||
      requestFormTable.value.tableDate6Lsit[i].quantity == ""
    ) {
      notifications.showMessage(
        "请在消耗辅助材料表第" + [i + 1] + "行，填写数量",
        "error"
      );
      return;
    }
  }
  //消耗（自制）费用项目
  for (let i = 0; i < requestFormTable.value.tableDate7Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate7Lsit[i].amount == 0 ||
      requestFormTable.value.tableDate7Lsit[i].amount == ""
    ) {
      notifications.showMessage(
        "请在消耗（自制）费用项目表第" + [i + 1] + "行，填写金额",
        "error"
      );
      return;
    }
  }
  //步骤设置
  for (let i = 0; i < requestFormTable.value.tableDate8Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate8Lsit[i].stepName == 0 ||
      requestFormTable.value.tableDate8Lsit[i].stepName == ""
    ) {
      notifications.showMessage("请在步骤设置表第" + [i + 1] + "行，填写工步", "error");
      return;
    }
    if (
      // requestFormTable.value.tableDate8Lsit[i].stepManHour == 0 ||
      requestFormTable.value.tableDate8Lsit[i].stepManHour == ""
    ) {
      notifications.showMessage("请在步骤设置表第" + [i + 1] + "行，工步工时", "error");
      return;
    }
    if (
      // requestFormTable.value.tableDate8Lsit[i].personnelNumber == 0 ||
      requestFormTable.value.tableDate8Lsit[i].personnelNumber == ""
    ) {
      notifications.showMessage("请在步骤设置表第" + [i + 1] + "行，人数", "error");
      return;
    }
  }
  //消耗（委外）费用项目
  for (let i = 0; i < requestFormTable.value.tableDate9Lsit.length; i++) {
    if (
      // requestFormTable.value.tableDate9Lsit[i].amount == 0 ||
      requestFormTable.value.tableDate9Lsit[i].amount == ""
    ) {
      notifications.showMessage(
        "请在消耗（委外）费用项目表第" + [i + 1] + "行，填写金额",
        "error"
      );
      return;
    }
  }
  isTrue.value = true;
};
const getAllData = async () => {
  //   if (requestFormTable.value.formMainTable.type == 0) {
  //     await isRole();
  //   } else {
  //     await isRole1();
  //   }
  //   if (isTrue.value) {
  //     return;
  //   }
  const res = await crud.sendRequest(
    "/Gri/add/GrindingProcessStandardMain/",
    "post",
    requestFormTable.value
  );
  OFFdialogTableVisible();
};
const getAllData3 = async () => {
  //   if (requestFormTable.value.formMainTable.type == 0) {
  //     await isRole();
  //   } else {
  //     await isRole1();
  //   }
  //   if (isTrue.value) {
  //     return;
  //   }
  const res = await crud.sendRequest(
    "/Gri/add/GrindingProcessStandardMain/",
    "post",
    requestFormTable.value
  );
};
const getAllData1 = async () => {
  //   if (requestFormTable.value.formMainTable.type == 0) {
  //     await isRole();
  //   } else {
  //     await isRole1();
  //   }
  //   if (isTrue.value) {
  //     return;
  //   }
  const res = await crud.sendRequest(
    "/Gri/add/GrindingProcessStandardMain/",
    "post",
    requestFormTable.value
  );
};
const updateMaterialsFixed = async () => {
  //   if (requestFormTable.value.formMainTable.type == 0) {
  //     await isRole();
  //   } else {
  //     await isRole1();
  //   }
  //   if (isTrue.value) {
  //     return;
  //   }
  const res = await crud.sendRequest(
    "/Gri/update/GrindingProcessStandardMain/",
    "post",
    requestFormTable.value
  );
  OFFdialogTableVisible();
};
const updateMaterialsFixed1 = async () => {
  //   if (requestFormTable.value.formMainTable.type == 0) {
  //     await isRole();
  //   } else {
  //     await isRole1();
  //   }
  //   if (isTrue.value) {
  //     return;
  //   }
  const res = await crud.sendRequest(
    "/Gri/update/GrindingProcessStandardMain/",
    "post",
    requestFormTable.value
  );
};
</script>
<style scoped>
.el-table {
  /* --el-table-row-hover-bg-color: rgba(0, 158, 250, 0.219) !important; */
  /* --el-table-row-hover-bg-color: #fef5f0 !important; */
  --el-table-row-hover-bg-color: rgba(254, 245, 240, 0.8) !important;
}

/* 选中 */
.el-table {
  /* --el-table-row-hover-bg-color: #fef5f0 !important; */
  --el-table-row-hover-bg-color: rgba(254, 245, 240, 0.8) !important;
}

.down-tree ::v-deep .el-tree-node.is-expanded > .el-tree-node__children {
  display: inline;
}

.down-tree {
  height: 100%;
}

.demo-pagination-block {
  float: right;
}

.custom-dialog {
  position: fixed;
  top: 10em;
  left: 50%;
  width: 20%;
  /* 其他样式... */
}

.labs {
  margin-bottom: 0px;
}

.lab {
  background-color: rgba(247, 247, 247, 0.903);
  text-align: center;
  margin-bottom: 0px;
  text-align: right;
}
.scrollbar-flex-content {
  width: 500px;
  margin-top: 5px;
  display: flex;
}
.scrollbar-demo-item {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 25px;
  text-align: center;
}
.scr {
  height: 40px;
  background-color: rgba(247, 247, 247, 0.903);
}
.custom-collapse-title {
  font-weight: bold;
  color: #333; /* 加重的颜色 */
}
.content {
  /* 设置一个较大的 z-index，确保它在折叠面板下方 */
  z-index: 1;
  /* 其他样式属性，例如宽度、高度等 */
}
</style>
